Skip to content

Commit 3ee759a

Browse files
Update dfx.mdx
1 parent f12f9d3 commit 3ee759a

File tree

1 file changed

+25
-44
lines changed

1 file changed

+25
-44
lines changed

docs/cli-reference/dfx/dfx.mdx

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,63 @@
1-
import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
1+
# Determining `dfx` version
22

3-
# dfx
3+
When invoked as `dfx`, `dfxvm` determines which version of `dfx` to use for execution by checking these criteria in order:
44

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`.
69

10+
#### 1. Command line
711

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`:
2613

2714
```bash
28-
dfx +0.15.0 deploy
15+
dfx +0.26.0 deploy
2916
```
3017

31-
### DFX_VERSION environment variable
18+
#### 2. `DFX_VERSION` environment variable
3219

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`:
3621

3722
```bash
38-
DFX_VERSION=0.15.0 dfx start --clean --background
23+
DFX_VERSION=0.26.0 dfx start --clean --background
3924
```
4025

41-
### dfx field in the current project's dfx.json
26+
#### 3. `dfx` field in the current project's `dfx.json`
4227

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.
4529

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.
4831

4932
For example:
5033

5134
```json
5235
{
53-
"dfx": "0.14.4",
36+
"dfx": "0.26.1",
5437
"canisters": { }
5538
}
5639
```
5740

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`.
6042

61-
### default_version in $HOME/.config/dfx/version-manager.json
43+
#### 4. `default_version` in `$HOME/.config/dfx/version-manager.json`
6244

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:
6546

6647
```json
6748
{
68-
"default_version": "0.15.0"
49+
"default_version": "0.26.0"
6950
}
7051
```
7152

7253
To configure the default dfx version, use the `dfxvm default` command:
7354

7455
```bash
75-
dfxvm default 0.15.1
56+
dfxvm default 0.26.1
7657
```
7758

78-
## Environment Variables
59+
## Environment variables
7960

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

Comments
 (0)