set DFX_VERSION so that dfx doesn't in turn forward to something else
prepend the dfx bin path to PATH so that any calls to dfx in package.json or build scripts will go to the right place
All dfx binaries to date look at DFX_VERSION and the "dfx" field in dfx json. If these indicate to use a different version of dfx, they forward to that version instead. By setting DFX_VERSION, we ensure that dfx won't forward to a different version.
Previous installed versions of dfx were installed to /usr/local/bin. While it's likely that the dfxvm bin directory is on the path, adding the dfx version bin directory to the path will ensure that any calls to dfx go to the right version.
$ echo '{ "dfx": "0.14.4" }' >dfx.json
$ ./dfx +0.15.0 cache show
Warning: The version of DFX used (0.14.4) is different than the version being run (0.15.0).
This might happen because your dfx.json specifies an older version, or DFX_VERSION is set in your environment.
We are forwarding the command line to the old version. To disable this warning, set the DFX_WARNING=-version_check environment variable.
/Users/ericswanson/.cache/dfinity/versions/0.14.4
After:
$ ./dfx +0.15.0 cache show
/Users/ericswanson/.cache/dfinity/versions/0.15.0
For the path piece, I tried calling dfx deploy (through the dfxvm proxy) without having the dfxvm bin dir on the path.
Before:
$ export PATH='<path without dfxvm bin directory>'
$ "/Users/ericswanson/Library/Application Support/org.dfinity.dfx/bin"/dfx deploy
Error: Failed while trying to deploy canisters.
/var/folders/7l/6w8kktld2xn8qfz_m84bx18c0000gn/T/generate-595dfa1d.sh: line 1: dfx: command not found
After:
$ ~/test-dfxvm/dfx build
...
Building frontend...
WARN: Building canisters before generate for Motoko
WARN: /Users/ericswanson/.cache/dfinity/versions/0.16.1/base/Array.mo:864.40-864.54: warning [M0155], operator may trap for inferred type
Nat
Generating type declarations for canister dd_backend:
src/declarations/dd_backend/dd_backend.did.d.ts
src/declarations/dd_backend/dd_backend.did.js
src/declarations/dd_backend/dd_backend.did
$
Checklist:
[x] I have edited the CHANGELOG accordingly.
[x] I have made corresponding changes to the documentation in docs/cli-reference.
Description
When proxying to dfx:
All dfx binaries to date look at DFX_VERSION and the "dfx" field in dfx json. If these indicate to use a different version of dfx, they forward to that version instead. By setting DFX_VERSION, we ensure that dfx won't forward to a different version.
Previous installed versions of dfx were installed to /usr/local/bin. While it's likely that the dfxvm bin directory is on the path, adding the dfx version bin directory to the path will ensure that any calls to dfx go to the right version.
Fixes https://dfinity.atlassian.net/browse/SDK-1362
How Has This Been Tested?
Added a test. Also:
Before:
After:
For the path piece, I tried calling
dfx deploy
(through the dfxvm proxy) without having the dfxvm bin dir on the path.Before:
After:
Checklist: