Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Homebrew check for installed gems?

I have a formula that depends on a gem. It has depends_on 'some-gem' => :ruby at the top. I am sure it is installed, since I can use it as intended and it’s there when running gem list. However, when trying to install the formula, it shows

my-formula: Unsatisfied dependency: some-gem
Homebrew does not provide Ruby dependencies; install with:
    gem install some-gem
Error: An unsatisfied requirement failed this build.

So, how does Homebrew check for installed gems?

like image 304
user137369 Avatar asked Jan 02 '26 00:01

user137369


1 Answers

The actual check that is run to detect installed gems and similar things is in /usr/local/Library/Homebrew/requirements/language_module_dependency.rb, which in the case of Ruby does:

/usr/bin/env ruby -rubygems -e require\ 'GEMNAME'

Note that this calls ruby from the path, so it could be affected by mixups there. Make sure you have the right ruby first in your path, have the right gem program that goes with ruby, and possibly add some debugging to your formula to see what environment it is running under.

like image 120
Peter Eisentraut Avatar answered Jan 03 '26 15:01

Peter Eisentraut



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!