tl;dr: cargo install does not place executables in your $PATH.
The basic problem is:
$CARGO_HOME is /workspace/.cargo,cargo install places executables in $CARGO_HOME/bin, and$PATH does not include $CARGO_HOME/bin.It is worth noting, however, that /home/gitpod/.cargo/bin is in PATH and should probably stay there -- it's where rustup and cargo put things in full/Dockerfile.
It looks like $CARGO_HOME is set by /home/gitpod/.profile:
# Set CARGO_HOME to reside in workspace if:
# - it's RUNTIME (/workspace present)
if [ -d /workspace ]; then
export CARGO_HOME=/workspace/.cargo
fi
I'm not sure where this comes from, but changing that section to this should work:
# Set CARGO_HOME to reside in workspace if:
# - it's RUNTIME (/workspace present)
#
# Then, if we set CARGO_HOME, update PATH.
if [ -d /workspace ]; then
export CARGO_HOME=/workspace/.cargo
export PATH=$CARGO_HOME/bin:$PATH
fi
If the thing that appends to ~/.profile is also open-source and you point me to it I'll happily make a PR for it.
After adjusting the PATH, I discovered another problem caused by this setup:
rustup doesn't like being installed outside of $CARGO_HOME
gitpod /workspace/polymorphos $ rustup toolchain install nightly
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2019-05-23, rust version 1.36.0-nightly (37ff5d388 2019-05-22)
info: downloading component 'rustc'
91.0 MiB / 91.0 MiB (100 %) 21.4 MiB/s ETA: 0 s
info: downloading component 'rust-std'
61.3 MiB / 61.3 MiB (100 %) 20.3 MiB/s ETA: 0 s
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
91.0 MiB / 91.0 MiB (100 %) 8.4 MiB/s ETA: 0 s
info: installing component 'rust-std'
61.3 MiB / 61.3 MiB (100 %) 11.8 MiB/s ETA: 0 s
info: installing component 'cargo'
info: installing component 'rust-docs'
11.0 MiB / 11.1 MiB (100 %) 3.2 MiB/s ETA: 0 s
nightly-x86_64-unknown-linux-gnu installed - rustc 1.36.0-nightly (37ff5d388 2019-05-22)
error: rustup is not installed at '/workspace/.cargo'
gitpod /workspace/polymorphos $
@duckinator thanks a lot for reporting this! I'll take care of this.
If the thing that appends to ~/.profile is also open-source and you point me to it I'll happily make a PR for it.
@geropl once described how to make these additions to bash profiles customizable which would simplify a lot of things. Stay tuned!
@duckinator Thank you for your detailed analysis! The path is indeed just missing.
After adjusting the PATH, I discovered another problem caused by this setup:
rustup doesn't like being installed outside of $CARGO_HOME
rustup reports this error anyway with our setup (rustup not being installed in CARGO_HOME), but seems to work 100% despite the error.
The current situation is a trade-off due to the way our persistence works:
CARGO_HOME) be stored under /workspace/.cargo because that is the folder which gets persisted between workspace restartsRUSTUP_HOME) to be located under /home/gitpod/.rustup because:The general recommendation for Rust is: If you want a custom/specific toolchains (rustup toolchain install ..) install it in your Dockerfile (like here for example)
TODO for me:
Thanks for all the info! I think I've got a working setup figured out, but I'll let y'all decide when to close this issue since it seems I did find some stuff you want to follow up on. :+1:
The fix is not yet deployed.
โฒ
deployed
Most helpful comment
@duckinator thanks a lot for reporting this! I'll take care of this.
@geropl once described how to make these additions to bash profiles customizable which would simplify a lot of things. Stay tuned!