Skip to content

Install env scripts in receipts dir instead of bin dir#2423

Open
Gankra wants to merge 5 commits into
mainfrom
gankra/rename-env
Open

Install env scripts in receipts dir instead of bin dir#2423
Gankra wants to merge 5 commits into
mainfrom
gankra/rename-env

Conversation

@Gankra
Copy link
Copy Markdown
Contributor

@Gankra Gankra commented Jun 4, 2026

This attempts to address one of the original cardinal sins of cargo-dist: that in flat installs we create a sourceable script called env in the bin dir, where it can shadow /usr/bin/env.

This sin was originally forced by us not having any other directory we could put these files in, along with historical momentum of cargo calling the file env.

Since then we have introduced receipts, which means we have another dir where we can shove other random non-executable stuff.

  • Renames env to env.sh because come on it's a shell script by any other name, even though it's only ever sourced
  • Makes us write env.sh and env.fish to the receipt dir
  • Adds migration logic to attempt to remove the old env and env.fish files from the bin dir, if they look like they were made by us
  • Adds migration logic to attempt to edit profiles to point to the new env files.

As always I am profoundly unconfident in my shell scripting (codex did most of it, but I don't even trust my reviews of shell code).

@Gankra Gankra added the bug Something isn't working label Jun 4, 2026
@mistydemeo
Copy link
Copy Markdown
Contributor

mistydemeo commented Jun 5, 2026

that in flat installs we create a sourceable script called env in the bin dir, where it can shadow /usr/bin/env.

ftr, we install env as non-executable. Shells will typically ignore a non-executable file when evaluating the PATH, so a non-executable env earlier in the PATH will not take precedence over /usr/bin/env. I tested just now with /bin/bash, Homebrew-installed bash 5.2, fish, zsh and dash, and confirmed none of them are picking the cargo-dist installed env script over /usr/bin/env.

Just to check, is this in response to a specific issue that someone ran into?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants