"Could not find gem '...' in locally installed gems" Upon Running Overcommit
None of overcommit commands run. They all produce this error:
Resolving dependencies........
Could not find gem 'cadence-ruby' in locally installed gems
Run `bundle install` to install missing gems.
However:
❯ bundle info cadence-ruby
* cadence-ruby (0.1.15)
Summary: Cadence Ruby client
Homepage: https://github.com/coinbase/cadence-ruby
Path: /Users/jeffsaremi/.rvm/gems/ruby-2.7.6/gems/cadence-ruby-0.1.15
Manually installing gem install cadence-ruby -v 0.1.15 does not help
However running overcommit commands (eg overcommit --run) with a bundle exec works. eg:
bundle exec overcommit --run
But still none of the git hooks run :
❯ git commit -am "removing dummy changes"
Problem loading 'Gemfile': Could not find gem 'cadence-ruby' in locally installed gems
Try running:
bundle install --gemfile=Gemfile
❯ bundle version
Bundler version 2.2.20 (2021-06-11 commit 4c510a34a4)
❯ ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin21]
not really a fix but a clutch: try installing both gems into MacOS default system ruby
Thanks Bodhan! I will try this and get back to you
I did this which still made no difference:
❯ sudo gem install --no-user-install cadence-ruby -v 0.1.15
Password:
Fetching thrift-0.17.0.gem
Fetching oj-3.13.23.gem
Fetching cadence-ruby-0.1.15.gem
Building native extensions. This could take a while...
GemWrappers: Can not wrap not executable file: codeowners
Successfully installed oj-3.13.23
Building native extensions. This could take a while...
GemWrappers: Can not wrap not executable file: codeowners
Successfully installed thrift-0.17.0
GemWrappers: Can not wrap not executable file: codeowners
Successfully installed cadence-ruby-0.1.15
Parsing documentation for oj-3.13.23
Installing ri documentation for oj-3.13.23
Parsing documentation for thrift-0.17.0
Installing ri documentation for thrift-0.17.0
Parsing documentation for cadence-ruby-0.1.15
Installing ri documentation for cadence-ruby-0.1.15
Done installing documentation for oj, thrift, cadence-ruby after 4 seconds
3 gems installed
❯ sudo gem install --no-user-install bundler
Fetching bundler-2.3.26.gem
GemWrappers: Can not wrap not executable file: codeowners
Successfully installed bundler-2.3.26
Parsing documentation for bundler-2.3.26
Installing ri documentation for bundler-2.3.26
Done installing documentation for bundler after 0 seconds
1 gem installed
❯ overcommit --run
Resolving dependencies.........
Could not find gem 'cadence-ruby' in locally installed gems
Run `bundle install` to install missing gems.
The issue I'm facing here is that I use rbenv to manage two Ruby versions locally: 2.6.10 and 2.7.8. When I use version 2.7.8, I encounter the problem described above. My final solution was to delete the contents of /Library/Ruby. I noticed that this directory contains Ruby gems for version 2.6, which might have caused caching conflicts.
I could not reproduce this with current Overcommit and Ruby 3.4.7. I used a disposable repository and private GEM_HOME, installed a locally built Overcommit gem there, and configured a separate project Gemfile with an additional dependency required by a custom hook. The installed Git hook, direct overcommit --run, and bundle exec overcommit --run all succeeded and actually ran the dependency-using hook.
The report does not include the project's Gemfile/lockfile or Overcommit configuration, and I could not recreate its Ruby 2.7/RVM gem selection mismatch from the available information. It is possible a later change has fixed this. Closing as unable to reproduce. If it recurs on a current version, a minimal Gemfile, .overcommit.yml, and the Ruby/GEM_HOME/GEM_PATH used by the failing hook would help isolate it without changing system gem installations.