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

Including .ruby-version in homebrew-core can force ruby version for Ruby scripts in /opt/homebrew/bin #173816

Closed
4 tasks done
mfdj opened this issue Jun 5, 2024 · 3 comments
Closed
4 tasks done
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age

Comments

@mfdj
Copy link

mfdj commented Jun 5, 2024

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config
HOMEBREW_VERSION: 4.3.3
ORIGIN: https://github.com/Homebrew/brew
HEAD: e130e47f23b8b806096f9ec4f2c193213b8ec908
Last commit: 3 days ago
Core tap JSON: 05 Jun 20:48 UTC
Core cask tap JSON: 05 Jun 20:48 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nano
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.2 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.2/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.44.0 => /opt/homebrew/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  [email protected]
  [email protected]

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  openssl@3

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I was using an internal Keg to install a cli tool written in Ruby script which used a shebang like this:

Contrived example /opt/homebrew/bin/my_cool_cli

#!/usr/bin/env ruby
puts "I am a very useful cli tool written in Ruby"

What happened (include all command output)?

$ my_cool_cli
rbenv: version `3.3.2' is not installed (set by /opt/homebrew/.ruby-version)

What did you expect to happen?

I expected that my_cool_cli would pick up my global ruby version

Step-by-step reproduction instructions (by running brew commands)

$ brew tap private-org/private-tap 
$ brew install private-org/private-tap/my-cool-cli
$ my_cool_cli
@mfdj mfdj added the bug Reproducible Homebrew/homebrew-core bug label Jun 5, 2024
@mfdj
Copy link
Author

mfdj commented Jun 5, 2024

It seems that homebrew-core recently #172596 began including .ruby-verison file

Which means that if you have rbenv installed and you're trying to run any Ruby script installed in /opt/homebrew/bin that uses an env shebang like #!/usr/bin/env ruby the rbenv version resolution algorithm will always choose the version described in /opt/homebrew/.ruby-version rather than the expected rbenv global version

@carlocab
Copy link
Member

carlocab commented Jun 6, 2024

See also Homebrew/brew#17390.

@MikeMcQuaid
Copy link
Member

Closing as duplicate of Homebrew/brew#17390. You may find the workarounds listed there to be helpful. To be clear: this issue adds weight to us making a change there.

@MikeMcQuaid MikeMcQuaid closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2024
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

3 participants