|
1 | | -import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow"; |
| 1 | +# Determining `dfx` version |
2 | 2 |
|
3 | | -# dfx |
| 3 | +When invoked as `dfx`, `dfxvm` determines which version of `dfx` to use for execution by checking these criteria in order: |
4 | 4 |
|
5 | | -<MarkdownChipRow labels={["Reference"]} /> |
| 5 | +1. `+<version>` parameter from command line. |
| 6 | +2. `DFX_VERSION` environment variable. |
| 7 | +3. `dfx` setting in the current project's `dfx.json`. |
| 8 | +4. `default_version` in `$HOME/.config/dfx/version-manager.json`. |
6 | 9 |
|
| 10 | +#### 1. Command line |
7 | 11 |
|
8 | | -When invoked as `dfx`, `dfxvm` determines which version of dfx to use |
9 | | -and dispatches execution to it. |
10 | | - |
11 | | -## dfx version determination |
12 | | - |
13 | | -`dfxvm` determines which version of dfx to use by checking these criteria |
14 | | -in order: |
15 | | - |
16 | | -1. `+<version>` parameter from command line |
17 | | -2. `DFX_VERSION` environment variable |
18 | | -3. `dfx` in the current project's `dfx.json` |
19 | | -4. `default_version` in `$HOME/.config/dfx/version-manager.json` |
20 | | - |
21 | | -### Command Line |
22 | | - |
23 | | -You can specify the version of dfx to use on the command line by passing |
24 | | -`+<version>` as the first parameter. For example, the following will deploy |
25 | | -using dfx 0.15.0: |
| 12 | +You can specify the version of `dfx` on the command line by passing `+<version>` as the first parameter. For example, the following will deploy using `dfx v0.26.0`: |
26 | 13 |
|
27 | 14 | ```bash |
28 | | -dfx +0.15.0 deploy |
| 15 | +dfx +0.26.0 deploy |
29 | 16 | ``` |
30 | 17 |
|
31 | | -### DFX_VERSION environment variable |
| 18 | +#### 2. `DFX_VERSION` environment variable |
32 | 19 |
|
33 | | -You can specify the version of dfx to use by setting the `DFX_VERSION` |
34 | | -environment variable. For example, the following will start the replica using |
35 | | -dfx 0.15.0: |
| 20 | +You can specify the version of `dfx` by setting the `DFX_VERSION` environment variable. For example, the following will start the local developer environment using `dfx v0.26.0`: |
36 | 21 |
|
37 | 22 | ```bash |
38 | | -DFX_VERSION=0.15.0 dfx start --clean --background |
| 23 | +DFX_VERSION=0.26.0 dfx start --clean --background |
39 | 24 | ``` |
40 | 25 |
|
41 | | -### dfx field in the current project's dfx.json |
| 26 | +#### 3. `dfx` field in the current project's `dfx.json` |
42 | 27 |
|
43 | | -If running dfxvm as dfx in a dfx project, and the project's dfx.json contains a |
44 | | -top-level field "dfx", then dfxvm will use the version specified in that field. |
| 28 | +A project's `dfx.json` file can contain a top-level field "dfx". If specified, then `dfxvm` will use that version. |
45 | 29 |
|
46 | | -Like dfx, dfxvm looks for dfx.json in the current directory and then in |
47 | | -parent directories until it finds one or reaches the root directory. |
| 30 | +Like `dfx`, `dfxvm` looks for `dfx.json` in the current directory and then in parent directories until it finds one or reaches the root directory. |
48 | 31 |
|
49 | 32 | For example: |
50 | 33 |
|
51 | 34 | ```json |
52 | 35 | { |
53 | | - "dfx": "0.14.4", |
| 36 | + "dfx": "0.26.1", |
54 | 37 | "canisters": { } |
55 | 38 | } |
56 | 39 | ``` |
57 | 40 |
|
58 | | -If the above dfx.json were in the current directory or any parent directory, |
59 | | -then any dfx command would use dfx 0.14.4. |
| 41 | +If the above `dfx.json` were in the current directory or any parent directory, then any `dfx` command would use `dfx v0.26.1`. |
60 | 42 |
|
61 | | -### default_version in $HOME/.config/dfx/version-manager.json |
| 43 | +#### 4. `default_version` in `$HOME/.config/dfx/version-manager.json` |
62 | 44 |
|
63 | | -If none of the above criteria are met, then dfxvm will use the version specified |
64 | | -in `$HOME/.config/dfx/version-manager.json`. For example: |
| 45 | +If none of the above criteria are met, then `dfxvm` will use the version specified in `$HOME/.config/dfx/version-manager.json`. For example: |
65 | 46 |
|
66 | 47 | ```json |
67 | 48 | { |
68 | | - "default_version": "0.15.0" |
| 49 | + "default_version": "0.26.0" |
69 | 50 | } |
70 | 51 | ``` |
71 | 52 |
|
72 | 53 | To configure the default dfx version, use the `dfxvm default` command: |
73 | 54 |
|
74 | 55 | ```bash |
75 | | -dfxvm default 0.15.1 |
| 56 | +dfxvm default 0.26.1 |
76 | 57 | ``` |
77 | 58 |
|
78 | | -## Environment Variables |
| 59 | +## Environment variables |
79 | 60 |
|
80 | | -When proxying to dfx, dfxvm alters the environment in two ways: |
81 | | -- Sets `DFX_VERSION` to the version of dfx being used. |
82 | | -- Prepends the bin directory for the dfx version to `PATH`. |
| 61 | +When proxying to `dfx`, `dfxvm` alters the environment in two ways: |
| 62 | +- Sets `DFX_VERSION` to the version of `dfx` being used. |
| 63 | +- Prepends the `bin` directory for the `dfx` version to `PATH`. |
0 commit comments