I have two systems, one is a fresh Linux install, the other a mac.
On macOS, when I run cargo --list --verbose
I can see all the inbuilt and externally-installed cargo commands:
% cargo --list --verbose
Installed Commands:
add Add dependencies to a Cargo.toml manifest file
b alias: build
bench Execute all benchmarks of a local package
build Compile a local package and all of its dependencies
build-bpf /Users/username/.local/share/solana/install/active_release/bin/cargo-build-bpf
build-sbf /Users/username/.local/share/solana/install/active_release/bin/cargo-build-sbf
...
On the Linux system, however, despite having the same software installed, the external commands are not shown:
% cargo --list --verbose
Installed Commands:
add Add dependencies to a Cargo.toml manifest file
b alias: build
bench Execute all benchmarks of a local package
build Compile a local package and all of its dependencies
c alias: check
...
However I can see the same file exists in the same directory:
# ls -la ~/.local/share/solana/install/active_release/bin
-rwxr-xr-x 1 username group 6924136 Mar 3 06:33 cargo-build-bpf
-rwxr-xr-x 1 username group 21154624 Mar 3 06:33 cargo-build-sbf
Why is my installed command not showing in 'cargo --list'?
I have checked PATH
and ~/.local/share/solana/install/active_release/bin
is in PATH
What can I do to ensure it appears? I have others tools that invoke cargo build-bpf
so running the binary outside cargo won't work.
Originally I thought this was a bug in Cargo, but it's actually GitHub actions. I've edited the post below to reflect that.
Cargo does use PATH to determine the location of the commands shown when you run cargo --list
:
3rd party subcommands (ie. programs named cargo-foobar placed in $PATH)...
However due to using GitHub actions, where the ~
is not expanded properly, my PATH was incorrect.
Normally (in bash), adding ~/somedir/bin
to PATH
would result in /home/username/somedir/bin
being added to PATH.
In GitHub actions, adding ~/somedir/bin
to GITHUB_PATH
won't expand the tilde, resulting in ~/somedir/bin
being added, which won't work.
To fix: ensure you do not use tilde when adding items to the PATH in GitHub actions, eg:
- name: Install Solana CLI (beta)
run: |
sh -c "$(curl -sSfL https://release.solana.com/beta/install)"
echo "~/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Install Solana CLI (beta)
run: |
sh -c "$(curl -sSfL https://release.solana.com/beta/install)"
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH