dvm setup [--dvm-path <path>] [--write-path-line | --remove-path-line]
Writes ~/.dvm/shims/dart (dart.bat on Windows) and tells you the one line that puts the shims on your
PATH — or adds it for you, with --write-path-line.
dvm setup
Wrote /Users/you/.dvm/shims/dart
-> /Users/you/.dvm/bin/dvm exec dart
Add this to ~/.zshrc:
export PATH="/Users/you/.dvm/shims:$PATH"
Then check it with: dvm doctor
Flags#
| Flag | Effect |
|---|---|
--dvm-path <path> |
The dvm binary to bake into the shim. Defaults to the running one; needed when running from source. |
--write-path-line |
Add the PATH line to your shell startup file instead of just printing it. Backs the file up first, and leaves it alone when the line is already there. |
--remove-path-line |
Take that line back out, leaving the shims in place. A line you added by hand stays yours. |
It prints the PATH line for you#
It prints the exact line and names the file it belongs in, so the change to your login shell stays yours to make. See The Shim and Your PATH for which file each shell reads.
And when you would rather dvm made the edit, --write-path-line does it:
dvm setup --write-path-line
Wrote /Users/you/.dvm/shims/dart
-> /Users/you/.dvm/bin/dvm exec dart
Backed up /Users/you/.zshrc -> /Users/you/.zshrc.dvm-backup-20260829-154646
Added this line to /Users/you/.zshrc:
export PATH="/Users/you/.dvm/shims:$PATH"
It takes effect in shells started after this. For the one you are in: source /Users/you/.zshrc
Undo it with: dvm setup --remove-path-line
Then check it with: dvm doctor
It copies the file to a timestamped backup first and writes the line between # >>> dvm >>>
and # <<< dvm <<<, so a second run finds it and adds nothing — and so
--remove-path-line knows which line is dvm's:
dvm setup --remove-path-line
Backed up /Users/you/.zshrc -> /Users/you/.zshrc.dvm-backup-20260829-154647
Removed dvm's PATH line from /Users/you/.zshrc.
Shells started after this will no longer find the shims. The shims themselves are still in /Users/you/.dvm/shims.
A line you typed yourself is recognised too — different quoting, or $HOME in place of your home directory, still counts as already on
PATH — and removal reports it and leaves it exactly as you wrote it.
On Windows#
PowerShell takes PATH from your user environment rather than from a startup file, so dvm setup
hands you the call that sets it:
Wrote C:\Users\you\.dvm\shims\dart.bat
-> C:\Users\you\.dvm\bin\dvm.exe exec dart
Run this once in PowerShell:
[Environment]::SetEnvironmentVariable('Path', 'C:\Users\you\.dvm\shims;' + [Environment]::GetEnvironmentVariable('Path', 'User'), 'User')
That edits your user PATH, so it survives a reboot. It has to go ahead of anything else that puts a dart on PATH, and it only takes effect in terminals opened after you run it.
For the terminal you are in right now:
$env:Path = 'C:\Users\you\.dvm\shims;' + $env:Path
Then check it with: dvm doctor
That writes to the User scope, so it needs no elevation. Git Bash and MSYS set $SHELL, so dvm gives them the POSIX
export line and the startup file that shell reads.
It needs a dvm binary to point at#
The shim contains an absolute path to a dvm binary, so dvm setup has to know where one is. Under
dart run bin/dvm.dart the running executable is the Dart VM, and a shim baked with that path would read
exec /path/to/dart exec dart "$@"
and hand exec dart to the SDK as arguments on every dart invocation on the machine. So dvm names the binary it wants instead of guessing:
dvm: dvm is running from source (via /Users/you/.dvm/versions/3.13.2/bin/dart), so it cannot tell where a dvm binary lives, and a shim pointing at the Dart VM would break every `dart` on this machine.
Compile it first: dart compile exe bin/dvm.dart -o /usr/local/bin/dvm
Or name the binary: dvm setup --dvm-path <path to dvm>
--dvm-path names the binary directly, which is the answer whenever dvm is running from source.
Exit code#
dvm setup exits 1 when it finds something that would leave the shim inert — most importantly a
shell function shadowing dvm, which the older
cbracken/dvm installs. The exit code tells you at the command that wrote the shim, rather than the next time you run
dart.
--write-path-line exits 1 for the same reason when it holds off: a function or alias named
dvm beats PATH outright, so the line would look like it worked and change nothing. It says so, leaves the file untouched, and asks you to clear the warning and run it again.
--remove-path-line exits 0 whether it removed dvm's block, found a line you wrote yourself, or found nothing to remove.
Re-running it#
Safe, and the right thing to do after moving or reinstalling the dvm binary — the shim contains an absolute path to it.
--write-path-line is safe to repeat too: the second run finds the line already there and says so.
See also#
-
The Shim and Your PATH — what the shim is, and why
PATHorder matters. dvm doctor— check that it worked.