1Environment Variables and Global Options 2======================================== 3 4Fossil uses a number of environment variables and supports a number 5of global options. Most of these seem to be primarily documented in 6the source code, with the primary exception of `--args` which is 7described in the usage text printed by running fossil with no 8arguments at all. 9 10 11 12Global Options 13-------------- 14 15The following options are understood by the fossil command itself, and 16are collected before any subcommand begins processing. 17 18`--args FILENAME`: Read the file `FILENAME` and replace these two 19arguments with its content. Each line of the file is assumed to be an 20argument unless it starts with '-' and contains a space, in which case 21it is assumed to be another flag and is treated as such. `--args 22FILENAME` may be used in conjunction with any other flags. 23 24`--case-sensitive BOOL`: Override the `case-sensitive` setting, which 25can override the native preferences of the platform for case sensitive 26file names: insensitive on Windows, sensitive on Unix. There are 27probably odd interactions possible if you mix case sensitive and case 28insensitive file systems on any single platform. This option or the 29global setting should be used to force the case sensitivity to the 30most sensible condition. 31 32`--chdir DIRECTORY`: Change to the named directory before processing 33any commands. 34 35 36`--comfmtflags NUMBER`: Specify flags that control how check-in comments 37and certain other text outputs are formatted for display. The flags are 38individual bits in `NUMBER`, which must be specified in base 10: 39 40 * _0_ — Uses the revised algorithm with no special handling. 41 42 * _1_ — Uses the legacy algorithm, other flags are ignored. 43 44 * _2_ — Trims leading and trailing carriage-returns and line-feeds 45 where they do not materially impact pre-existing formatting 46 (i.e. at the start of the comment string _and_ right before 47 line indentation). 48 49 * _4_ — Trims leading and trailing spaces where they do not materially 50 impact the pre-existing formatting (i.e. at the start of the 51 comment string _and_ right before line indentation). 52 53 * _8_ — Attempts to break lines on word boundaries while honoring the 54 logical line length. 55 56 * _16_ — Looks for the original comment text within the text being 57 printed. Upon matching, a new line will be emitted, thus 58 preserving more of the pre-existing formatting. 59 60 61`--comment-format NUMBER`: Alias for `--comfmtflags NUMBER`. 62 63 64`--errorlog ERRLOG`: Name a file to which fossil will log panics, 65errors, and warnings. 66 67 68`--help`: If `--help` is found anywhere on the command line, translate 69the command to `fossil help cmdname` where `cmdname` is the first 70argument that does not begin with a `-` character. If all arguments 71start with `-`, translate to `fossil help argv[1] argv[2]...`. 72 73`--httptrace`: (Sets `g.fHttpTrace`.) Trace outbound HTTP requests. 74 75`--localtime`: Override the `timeline-utc` option to explicitly use 76local time. 77 78`--nocgi`: Prevent fossil from acting as a CGI by default even if the 79`GATEWAY_INTERFACE` environment variable is set. 80 81`--no-th-hook`: (Sets `g.fNoThHook`.) Override the `th1-hooks` setting 82and prevent any TH1 hooks from being executed. 83 84`--quiet`: (Sets `g.fQuiet`.) Cause fossil to suppress various messages and progress 85indicators that would otherwise be printed. 86 87`--sqltrace`: (Sets `g.SqlTrace`.) Implies `--sqlstats`. Trace certain 88SQLite database activity, especially showing every SQL query 89processed. 90 91`--sqlstats`: (Sets `g.fSqlStats`.) Print a number of performance 92statistics about each SQLite database used when it is closed. 93 94`--sshtrace`: (Sets `g.fSshTrace`.) 95 96`--ssl-identity`: The fully qualified name of the file containing the client 97certificate and private key to use, in PEM format. It can be created by 98concatenating the client certificate and private key files. This identity will 99be presented to SSL servers to authenticate the client, in addition to the 100normal password authentication. 101 102`--systemtrace`: (Sets `g.fSystemTrace`.) Trace all commands launched 103as sub processes. 104 105`--user LOGIN`: (Sets `g.zLogin`) Also `-U LOGIN`. Set the user name 106used with the repository. 107 108`--utc`: Override the `timeline-utc` option to explicitly use 109UTC time. 110 111`--vfs VFSNAME`: Load the named VFS into SQLite. 112 113 114Environment Variables 115--------------------- 116 117The location of the user's account-wide [configuration database][configdb] 118depends on the operating system and on the existence of various 119environment variables and/or files. See the discussion of the 120[configuration database location algorithm][configloc] for details. 121 122`EDITOR`: Name the editor to use for check-in and stash comments. 123Overridden by the local or global `editor` setting or the `VISUAL` 124environment variable. 125 126`FOSSIL_BREAK`: If set, an opportunity will be created to attach a 127debugger to the Fossil process prior to any significant work being 128performed. 129 130`FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets 131will be required to go through moderation (even those performed by the 132local interactive user via the command line). This can be useful for 133local (or remote) testing of the moderation subsystem and its impact 134on the contents and status of tickets. 135 136`FOSSIL_FORCE_WIKI_MODERATION`: If set, *ALL* changes for wiki pages 137will be required to go through moderation (even those performed by the 138local interactive user via the command line). This can be useful for 139local (or remote) testing of the moderation subsystem and its impact 140on the contents and status of wiki pages. 141 142 143`FOSSIL_HOME`: Location of [configuration database][configdb]. 144See the [configuration database location][configloc] description 145for additional information. 146 147`FOSSIL_USE_SEE_TEXTKEY`: If set, treat the encryption key string for 148SEE as text to be hashed into the actual encryption key. This has no 149effect if Fossil was not compiled with SEE support enabled. 150 151 152`FOSSIL_USER`: Name of the default user account if the checkout, local 153or global `default-user` setting is not present. The first environment 154variable found in the environment from the list `FOSSIL_USER`, `USER`, 155`LOGNAME`, and `USERNAME` is the user name. If none of those are set, 156then the default user name is "root". See the discussion of Fossil 157Username below for a lot more detail. 158 159 160`FOSSIL_SECURITY_LEVEL`: If set to any of the values listed below, 161additional measures for password security will be enabled (also see 162[How To Use Encrypted Repositories][encryptedrepos.wiki]): 163 164[encryptedrepos.wiki]: /doc/trunk/www/encryptedrepos.wiki 165 166 * _≥1_ — Do not remember passwords. 167 168 * _≥2_ — Use a scrambled matrix for password input. 169 170 171`FOSSIL_TCL_PATH`: When Tcl stubs support is configured, point to a 172specific file or folder containing the version of Tcl to load at run 173time. 174 175`FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT`: When set to the literal 176value `YES_DO_IT`, the test suite will relax the constraint that some 177tests may not run within an open checkout. This is subject to removal 178in the future. 179 180`FOSSIL_VFS`: Name a VFS to load into SQLite. 181 182`GATEWAY_INTERFACE`: If present and the `--nocgi` option is not, assume 183fossil is invoked from a web server as a CGI command, and act 184accordingly. 185 186`HOME`: Potential location of the [configuration database][configdb]. 187See the [configuration database location][configloc] description for details. 188 189`HOMEDRIVE`, `HOMEPATH`: (Windows) Location of the `~/.fossil` file. 190The first environment variable found in the environment from the list 191`FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows), 192`HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is 193used as the location of the `~/.fossil` file. 194 195`HTTP_HOST`: If defined, included in error log messages. 196 197`http_proxy`: If the global or local settings `proxy` is not set, this 198is used as the default value for the `proxy` setting. 199 200 201`HTTP_USER_AGENT`: If defined, included in error log messages. 202 203 204`LOCALAPPDATA`: (Windows) Location of the `~/.fossil` file. The first 205environment variable found in the environment from the list 206`FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows), 207`HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is 208used as the location of the `~/.fossil` file. 209 210`LOGNAME`: Name of the logged in user on many Unix-like platforms. 211Used as the fossil user name if `FOSSIL_USER` is not specified. See 212the discussion of Fossil Username below for a lot more detail. 213 214`PATH`: Used by most platforms to locate programs invoked without a 215fully qualified name. Explicitly used by `fossil ui` on certain platforms 216to choose the browser to launch. 217 218`PATH_INFO`: If defined, included in error log messages. 219 220`QUERY_STRING`: If defined, included in error log messages. 221 222`REMOTE_ADDR`: If defined, included in error log messages. 223 224`REMOTE_HOST`: Used by `fossil http` run from `stunnel` to identify 225the remote host. 226 227`REQUEST_METHOD`: If defined, included in error log messages. 228 229`REQUEST_URI`: If defined, included in error log messages. 230 231`SCRIPT_NAME`: If defined, included in error log messages. 232 233`SSH_CONNECTION`: Informs CGI processing if the remote client is SSH. 234 235`SQLITE_FORCE_PROXY_LOCKING`: From `sqlite3.c`, 1 means force always 236use proxy, 0 means never use proxy, and undefined means use proxy for 237non-local files only. 238 239`SQLITE_TMPDIR`: Names the temporary file location for SQLite. When 240set, this will be used instead of `TMPDIR`. 241 242 243`SYSTEMROOT`: (Windows) Used to locate `notepad.exe` as a 244fall back comment editor. 245 246`TERM`: If the linenoise library is used (almost certainly not on 247Windows), it will check `TERM` to verify that the interactive terminal 248is not named on a short list on terminals known to not work with 249linenoise. Linenoise is a library that provides command history and 250command line editing to interactive programs, and can be used in the 251`fossil sqlite3` command. 252 253`TH1_DELETE_INTERP`: Set this variable to ask fossil to explicitly 254delete the TH1 interpreter, if it is loaded, then check that it 255released all of its allocated memory, when exiting fossil. This is not 256strictly necessary, but makes debugging memory leaks easier. See 257[main.c near line 386](/artifact/e75796be5338a81c?ln=386,391) for the 258code. 259 260`TH1_ENABLE_DOCS`: Override the local or global setting `tcl-docs` 261to enable TH1 documents in fossil. 262 263`TH1_ENABLE_HOOKS`: Override the local or global setting `tcl-hooks` 264to enable TH1 hooks in fossil. 265 266`TH1_ENABLE_TCL`: Override the local or global setting `tcl` to enable 267Tcl in fossil. 268 269`TH1_TEST_ANON_CAPS`: Override the default anonymous permissions used 270when processing the `--set-anon-caps` option for the `test-th-eval`, 271`test-th-render`, and `test-th-source` test commands. 272 273`TH1_TEST_USER_CAPS`: Override the default user permissions used when 274processing the `--set-user-caps` option for the `test-th-eval`, 275`test-th-render`, and `test-th-source` test commands. 276 277`TMPDIR`: Names the temporary file location for SQLite. 278 279 280`USER`: Name of the logged in user on many Unix-like platforms. 281Used as the fossil user name if `FOSSIL_USER` is not specified. See 282the discussion of Fossil Username below for a lot more detail. 283 284`USERNAME`: Name of the logged in user on Windows platforms. 285Used as the fossil user name if `FOSSIL_USER` is not specified. See 286the discussion of Fossil Username below for a lot more detail. 287 288`VISUAL`: Name the editor to use for check-in and stash comments. 289Overrides the `EDITOR` environment variable. Overridden by the local 290or global `editor` setting. 291 292 293 294Notes on Related Values 295----------------------- 296 297### CGI and JSON Parameters 298 299 300The JSON API implementation looks up many values in the first of 301several places searched. This unifies the parameter handling logic, 302allows the caller to choose whether to prefer URL parameters, request 303headers, or the POST payload, and allows the `fossil json` command to 304share most of the same logic as the `/json` API path. The search order 305is a POST payload, GET/COOKIE/non-JSON POST, JSON POST, the system 306environment. 307 308See the comment above the implementation of [`json_getenv`][json.c] 309for some further discussion. 310 311[json.c]: /artifact/6df1d80dece8968b?ln=277,290 312 313### Comment Editor 314 315The editor used to edit a check-in or stash comment is named by the 316local or global setting `editor`. If neither is set, then the environment 317variables `VISUAL`, and `EDITOR` are checked in that order. 318 319On Windows, if no editor is named, then Notepad is used. Note that the 320operation will be aborted if `notepad.exe` is not found in the Windows 321folder. 322 323On Unix-like platforms, if no editor is named, then a message is 324displayed on stdout, and stdin is read until a single line containing 325only a dot is seen. 326 327 328### Error logging 329 330If logging errors to a file, fossil will include the values of the 331following environment variables in the error log entry if they are 332defined: `HTTP_HOST`, `HTTP_USER_AGENT`, `PATH_INFO`, `QUERY_STRING`, 333`REMOTE_ADDR`, `REQUEST_METHOD`, `REQUEST_URI`, and `SCRIPT_NAME`. 334 335 336 337### Fossil Username 338 339In absence of any explicit setting, fossil will use the same name you 340logged in to your platform with, as the user name when interacting 341with local and remote repositories. Note that only the name is shared, 342fossil makes no attempt to share or leverage any platform's 343authentication mechanisms or passwords. 344 345When logging in to a repository, it tries a series of sources for the 346user name, and the first non-blank name that succeeds is the logged in 347user. The order is: 348 3491. The --user and -U command-line options. 3502. If running within an open checkout (the local database is open), 351 check in its table of values stored per open checkout for the 352 value stored by `fossil user default USERNAME`. 3533. The default user in the repository (setting `default-user`) 3544. The `FOSSIL_USER` environment variable. 3555. The `USER` environment variable. 3566. The `LOGNAME` environment variable. 3577. The `USERNAME` environment variable. 3588. Check if the user can be extracted from the remote URL, if 359 there is a remote URL. 360 361Items 2 and 3 are both set by `fossil user default USERNAME`, the 362first within an open checkout, the second outside and using the `-R 363REPOSITORY` option to identify the repository. Both cases require that 364the named user be present in the repository when the default user is 365assigned. Although the default user is internally stored as if it were 366a setting named `default-user`, it is not accessible through 367the `fossil set` command. 368 369Items 5, 6, and 7 cover most of the names of an environment variable 370set automatically by the platform with the name of the platform's 371logged in user for use by programs. Historically, `USER` comes from 372Unix System-V, `LOGNAME` from BSD, and `USERNAME` from Windows, but 373many Linux distributions will set both `USER` and `LOGNAME` for broad 374compatibility. 375 376When creating a new repository, fossil needs a user name for the admin 377user granted the "s" permission. But since fossil generally expects 378that `fossil new` or `fossil clone` are used outside of any checkout 379(especially when run for the first time without any checkouts at all 380or the users's global settings database), it looks in a shorter list 381of places for a non-blank name. In the special case of a clone, 382`default-user` can be copied from the original, and so it can be set 383in the clone even before any users have been created, and in that case 384it will be the new admin user. If `default-user` is not set, then the 385first found environment variable from the list `FOSSIL_USER`, `USER`, 386`LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if 387none of those are set, then the default user name is "root". 388 389 390### Configuration Database Location 391 392Fossil keeps some information pertinent to each user in the user's 393[configuration database file][configdb]. 394The configuration database file includes the global settings 395and the list of repositories and checkouts used by `fossil all`. 396 397The location of the configuration database file depends on the 398operating system and on the existence of various environment 399variables and/or files. In brief, the configuration database is 400usually: 401 402 * Traditional unix → "`$HOME/.fossil`" 403 * Windows → "`%LOCALAPPDATA%/_fossil`" 404 * [XDG-unix][xdg] → "`$HOME/.config/fossil.db`" 405 406[xdg]: https://www.freedesktop.org/wiki/ 407 408See the [configuration database location 409algorithm][configloc] discussion for full information. 410 411### SQLite VFS to use 412 413See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an 414explanation of what a VFS actually is and what it does. 415 416If the default VFS underneath SQLite is not suitable, an alternative 417can be selected with either the `--vfs VFSNAME` option or the 418`FOSSIL_VFS` environment variable. The `--vfs` option takes 419precedence. 420 421 422### <a id="temp"></a>Temporary File Location 423 424Fossil places some temporary files in the checkout directory. Most notably, 425supporting files related to merge conflicts are placed in the same 426folder as the merge result. 427 428Other temporary files need a different home. The rules for choosing one are 429complicated. 430 431Fossil-specific code uses `FOSSIL_TEMP`, `TEMP`, and `TMP`, in that 432order. Fossil’s own test suite prepends `FOSSIL_TEST_TEMP` to that list. 433 434The underlying SQLite code uses several different path sets for its temp 435files, depending on the platform type. 436 437On Unix-like platforms, excepting Cygwin, SQLite first checks the 438environment variables `SQLITE_TMPDIR` and `TMPDIR`, in that order. If 439neither is defined, it falls back to a hard-coded list of paths: 440`/var/tmp`, `/usr/tmp`, and `/tmp`. If all of that fails, it uses the 441current working directory. 442 443For Cygwin builds, SQLite instead uses the first defined variable in 444this list: `SQLITE_TMPDIR`, `TMPDIR`, `TMP`, `TEMP`, and `USERPROFILE`. 445 446For native Windows builds, SQLite simply calls the OS’s [`GetTempPath()` 447API][gtp]. See that reference page for details. 448 449[gtp]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx 450 451 452 453That said, it is not unusual for utilities on all platforms to assume 454that `TEMP` or `TMP` point somewhere safe for temporary files. 455 456If the identified temporary folder is not writable, then weird things 457will happen on all platforms. 458 459 460### Web browser 461 462Occasionally, fossil wants to launch a web browser for the user, most 463obviously as part of the `fossil ui` command. In that specific case, 464the browser is launched pointing at the web server started by `fossil 465ui` listening on a private TCP port. 466 467On all platforms, if the local or global settings `web-browser` is 468set, that is the command used to open an URL. 469 470Otherwise, the specific actions vary by platform. 471 472On Unix-like platforms other than Apple's, it looks for the first 473program from the list `xdg-open`, `gnome-open`, `firefox`, and 474`google-chrome` that it can find on the `PATH`. 475 476On Apple platforms, it assumes that `open` is the command to open an 477URL in the user's configured default browser. 478 479On Windows platforms, it assumes that `start` is the command to open 480an URL in the user's configured default browser. 481 482[configdb]: ./tech_overview.wiki#configdb 483[configloc]: ./tech_overview.wiki#configloc 484