How to make Homebrew use non-system Ruby?

(Rafael A O Paulucci) #1

~I am having some trouble running brew cask audit tests because Homebrew (at least according to brew config) keeps using the macOS-provided Ruby for the rubocop gems et. al., even when force-linking, both with rbenv and with plain Homebrew ruby.~

EDIT: After running rm -rf /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.3.0 and attempting to run brew cask style again, it works. However, this issue has been reported in other threads (here: Cannot install rubocop related gems), so I believe it might be an actual bug.

Original question: Is there any way to force Homebrew to use a user-defined Ruby for its own purposes, so I can know where the gems are going? Also, why does Homebrew use its own 2.3.0 specifically?

brew config output:

HEAD: 8f74ba0197635b6ac7b03ea4eb7297d416fcf91a
Last commit: 4 hours ago
Core tap ORIGIN:
Core tap HEAD: 7622ef3e0517780171dfdaec762625a3d10ea3e5
Core tap last commit: 28 minutes ago
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.19.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_181
macOS: 10.14-x86_64
Xcode: 10.0
XQuartz: 2.7.11 => /opt/X11
Your system is ready to brew.

(Sean Molenaar) #2

If you believe it’s a bug, could you report it to the repo (if nobody else beat you to it?)

(Rafael A O Paulucci) #3

Well, I am not sure exactly what steps it would take to reproduce it. All I said was that it seems to have affected at least one other user as well.

To make matters worse, I also upgraded from High Sierra to Mojave between the (previously) last known working time of brew style and the time when the problem appeared. After that, I reinstalled Homebrew and rbenv, so there are too many variables to take into account.

Since there is no clear way for me to communicate to developers how to reproduce it, I think it might be better to hold off on reporting it now, as it risks being insta-closed.

For now, the workaround (if someone else has this problem) is just to delete the folder I mentioned and re-run brew style. This redownloads the required gems automatically.

Back to the original reason for this thread: is there a way to set an environment variable (either in Bash itself or internally through a brew command) to make Brew use a Ruby version chosen by the user?

(Sean Molenaar) #4

Closest I could find was HOMEBREW_FORCE_VENDOR_RUBY in the man page.