-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
/opt/homebrew/.ruby-version
overrides rbenv global
and causes errors for scripts using #!/usr/bin/env ruby
#17390
Comments
Sorry, this issue probably belongs in https://github.com/Homebrew/brew not |
Yea, we should probably move that |
It needs to live in the repository root if we want it to work as a We could move it to Ideally we can fix this without moving but it can be moved if that's the only way to resolve this. |
The only workaround here is to uninstall I'm not sure what you are trying to do, but can you somehow use the https://github.com/rbenv/rbenv?tab=readme-ov-file#environment-variables |
What about having a |
That would work fine, if I wonder if there's a possible solution here using something like |
I've been thinking about why no-one else has complained about this and I think this is the main culprit after rereading:
This is why Homebrew's packages either avoid (or attempt to avoid) the We'll consider making changes if more people chime in here but I think for now the best workarounds for you would be one of:
Basically: the same as any other Ruby project: have Ruby tooling use the correct/consistent Ruby version in the Homebrew repository. |
The If this is discouraged for Homebrew, what is the portable alternative? I use these scripts in non-Homebrew environments, so they need to be agnostic from the real location of the |
That's up to you. I see many potential solutions including not using |
I think this is the usual pattern for things like this: depends_on "ruby"
def install
libexec.install "myscript.rb"
(bin/"myscript").write_env_script libexec/"myscript.rb", PATH: "#{Formula["ruby"].opt_bin}:$PATH"
end This way the script is guaranteed to run in a predictable way with the Homebrew |
Related: Homebrew/homebrew-core#173816 |
@MikeMcQuaid said:
For clarification, I'm not using As a workaround, I think I can use
Yes, but now I am at the whim of whatever version Homebrew is using. Since I opened this issue, @reitermarkus: That pattern would unfortunately not work well for my tap. FWIW, my tap is just a single directory with a bunch of relatively small single-file scripts in it. Some are Ruby, some are Python, and some are Perl. They all use def install
system "make", "install", "PREFIX=#{prefix}"
end Using I'm sorry, I'm not trying to be difficult, but just pointing out how inconvenient this change is. |
This will avoid issues with `#!/usr/bin/env ruby` shebangs in Homebrew's prefix. Fixes #17390
Thank you! @MikeMcQuaid In the spirit of saying nice things when filing bugs, Homebrew is really fantastic and the first thing I install on a new Mac. It one of my few "must have" tools. Thank you (and everyone else) for all the work you've put into it! |
Thanks for the kind words @ddribin and for politely explaining the situation and bearing with me while I change my mind 😁 |
brew gist-logs <formula>
link ORbrew config
ANDbrew doctor
outputI tried removing
python-lxml
, but it is used by another formula:Verification
brew doctor
output saysYour system is ready to brew.
and am still able to reproduce my issue.brew update
and am still able to reproduce my issue.brew doctor
and that did not fix my problem.What were you trying to do (and why)?
I have
rbenv
installed via Homebrew and I have some personal scripts from a personal tap installed that use#!/usr/bin/env ruby
, for portability. For example:What happened (include all command output)?
Running these scripts results in an error due to
/opt/homebrew/.ruby-version
. This is a recent issue, and has worked for years up until I updated `brew today.Even
ruby
fails:Somehow
/opt/homebrew/.ruby-version
is overridingrbenv global
:What did you expect to happen?
I have
rbenv
setup to use thesystem
version, so these should end up using/usr/bin/ruby
, but/opt/homebrew/.ruby-version
overrides this:This worked until
.ruby-version
was added with 3392226Step-by-step reproduction instructions (by running
brew
commands)The text was updated successfully, but these errors were encountered: