Rustup: Error: "could not amend shell profile" when HOME is unwritable

Created on 5 Oct 2019  路  6Comments  路  Source: rust-lang/rustup

Problem

When CARGO_HOME and RUSTUP_HOME point to a location outside of $HOME, the rustup installer still tries to write to $HOME/.profile and then errors with:

error: could not amend shell profile: '/Users/builder/.profile'
info: caused by: could not write rcfile file: '/Users/builder/.profile'
info: caused by: Permission denied (os error 13)

I can't find how to prevent rustup from touching the user .profile or proceed with installation even though it fails to update .profile.

Steps

We run rustup on a somewhat restricted and perishable MacOS 10.11 virtual machine where user $HOME is unwritable. Hence on each build, we need to install cargo like so:

export CARGO_HOME="${TMPDIR}/.cargo"
export RUSTUP_HOME="${TMPDIR}/.rustup"
curl https://sh.rustup.rs -sSf | bash -s -- -y

And then in another script, we can use the following command to build stuff:

CARGO_HOME=${TMPDIR}/.cargo RUSTUP_HOME=${TMPDIR}/.rustup  \
  ${CARGO_HOME}/bin/cargo build --release --manifest-path=myrustlib/Cargo.toml

This works, but the rustup installation error about $HOME/.profile keeps showing.

Possible Solutions

  1. A variable or option to opt-out of automatically updating the user .profile.
  2. Turn this into a warning instead of an error, such that installation can proceed.

Notes

  • System: MacOS 10.11
  • Rustup: latest
bug

Most helpful comment

Thanks. Where do I pass this exactly? Like so ?

curl https://sh.rustup.rs -sSf | bash -s -- -y --no-modify-path

All 6 comments

You probably want to pass --no-modify-path to the installer.

Thanks. Where do I pass this exactly? Like so ?

curl https://sh.rustup.rs -sSf | bash -s -- -y --no-modify-path

Yep that's exactly right. The --no-modify-path is equivalent to telling the interactive installer that you don't want it to try and alter your profile. It will still write the env file to CARGO_HOME for you to use.

Thanks!

I have the same issue but currently the command is:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

this path doesn't support your --no-modify-path

add -s -- --no-modify-path?

Was this page helpful?
0 / 5 - 0 ratings