diff --git a/install-php-extensions b/install-php-extensions index 7888fe2..1ecf13e 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -2617,15 +2617,31 @@ installCargo() { if command -v cargo >/dev/null; then return fi - printf '# Installing cargo\n' - case "$DISTRO" in - alpine) - # see https://github.com/hyperledger/indy-vdr/issues/69#issuecomment-998104850 - export RUSTFLAGS='-C target-feature=-crt-static' - ;; - esac - curl https://sh.rustup.rs -sSf | sh -s -- -y -q + installCargo_cargoversion= + if ! test -f "$HOME/.cargo/env"; then + printf '# Installing cargo\n' + case "$DISTRO" in + alpine) + # see https://github.com/hyperledger/indy-vdr/issues/69#issuecomment-998104850 + export RUSTFLAGS='-C target-feature=-crt-static' + ;; + esac + curl https://sh.rustup.rs -sSf | sh -s -- -y -q + case "$DISTRO" in + alpine) + if test $DISTRO_MAJMIN_VERSION -le 310; then + # With version 1.84.0 we have this error: + # Error relocating /root/.rustup/toolchains/stable-x86_64-unknown-linux-musl/bin/cargo: posix_spawn_file_actions_addchdir_np: symbol not found + # See https://github.com/rust-lang/rust/pull/131851#issue-2595663507 + installCargo_cargoversion=1.83.0 + fi + ;; + esac + fi . "$HOME/.cargo/env" + if test -n "$installCargo_cargoversion"; then + rustup default -- "$installCargo_cargoversion" + fi if test -z "${IPE_UNINSTALL_CARGO:-}"; then IPE_UNINSTALL_CARGO=y fi @@ -4961,8 +4977,12 @@ fixLetsEncrypt() { # Cleanup everything at the end of the execution cleanup() { if test "${IPE_UNINSTALL_CARGO:-}" = y; then - . "$HOME/.cargo/env" - rustup self uninstall -y + if test -f "$HOME/.cargo/env"; then + . "$HOME/.cargo/env" + fi + if command -v rustup >/dev/null; then + rustup self uninstall -y + fi fi if test -n "$UNNEEDED_PACKAGE_LINKS"; then printf '### REMOVING UNNEEDED PACKAGE LINKS ###\n'