Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of hardlinks to a symlinked toolchain is not portable on macOS #3136

Closed
brotskydotcom opened this issue Jan 7, 2023 · 0 comments · Fixed by #3137
Closed

use of hardlinks to a symlinked toolchain is not portable on macOS #3136

brotskydotcom opened this issue Jan 7, 2023 · 0 comments · Fixed by #3137
Labels

Comments

@brotskydotcom
Copy link
Contributor

brotskydotcom commented Jan 7, 2023

Problem

rustup always uses hard links to the rustup executable on file systems that allow it, even if the rustup "executable" is itself a symlink. On macOS, which supports both filesystems that allow hard links to symlinks and filesystems that don't, this creates a portability problem; for example, you can't always copy (or backup) a rust install from one volume to another.

Steps

On a Mac with both an HFS+ volume and an AFS volume:

  1. install brew rustup-init.
  2. run rustup-init with a home directory on the AFS volume. This will result in hardlinks to rustup which is itself a symlink, as shown in this listing:
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 cargo@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 cargo-clippy@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 cargo-fmt@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 cargo-miri@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 clippy-driver@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rls@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rust-gdb@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rust-gdbgui@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rust-lldb@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rustc@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rustdoc@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rustfmt@ -> /opt/homebrew/bin/rustup-init
    lrwxr-xr-x  13 dbrotsky  staff  29 Jan  6 23:28 rustup@ -> /opt/homebrew/bin/rustup-init
    
  3. Try copying (or backing up) the .cargo directory to the HFS+ filesystem. This will fail.

Possible Solution(s)

While one option would be always to use symlinks on Mac, as is done on Android, that's a bigger change than needed, since arguably most rustup installs place an actual executable for rustup itself (and hard links to executables are supported on all macOS filesystems). The more cautious change is to detect whether rustup is a symlink and, if so, use a symlink to it rather than a hard link.

Notes

No response

Rustup version

rustup 1.25.1 (2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.66.0 (69f9c33d7 2022-12-12)`

Installed toolchains

Default host: aarch64-apple-darwin
rustup home:  /Users/dbrotsky/.rustup

stable-aarch64-apple-darwin (default)
rustc 1.66.0 (69f9c33d7 2022-12-12)
brotskydotcom added a commit to brotskydotcom/rustup that referenced this issue Jan 7, 2023
brotskydotcom added a commit to brotskydotcom/rustup that referenced this issue Jan 7, 2023
@brotskydotcom brotskydotcom changed the title use of hardlinks to a symlinked toolchain is not portable on MacOS use of hardlinks to a symlinked toolchain is not portable on macOS Jan 7, 2023
brotskydotcom added a commit to brotskydotcom/rustup that referenced this issue Jan 7, 2023
brotskydotcom added a commit to brotskydotcom/rustup that referenced this issue Jan 7, 2023
brotskydotcom added a commit to brotskydotcom/rustup that referenced this issue Jan 7, 2023
brotskydotcom added a commit to brotskydotcom/rustup that referenced this issue Feb 23, 2023
Darunada pushed a commit to Darunada/rustup that referenced this issue Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant