DarthSim / overmind

Process manager for Procfile-based applications and tmux
MIT License
2.82k stars 79 forks source link

`GemNotFoundException` when not using default ruby as specified by `rvm` #133

Closed jared-thoughtbot closed 2 years ago

jared-thoughtbot commented 2 years ago

Problem

When using rvm and trying to run overmind start it fails with Could not find 'bundler' (1.17.3) required by your /home/jaredt/projects/maitre-d/Gemfile.lock. (Gem::GemNotFoundException).

I seem to have narrowed this down to when using rvm and having the necessary ruby version installed and in use, but it not being the default rvm ruby.

Steps to reproduce

What you expected to see

The various services start up

What you saw instead

$ overmind start
system | Tmux socket name: overmind-maitre-d-HcwVIZlk8gsSWMQNOnGyTf
system | Tmux session ID: maitre-d
system | Listening at ./.overmind.sock
web    | Started with pid 15814...
worker | Started with pid 15816...
web    | Traceback (most recent call last):
web    |        4: from /home/jaredt/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `<main>'
web    |        3: from /home/jaredt/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `eval'
web    |        2: from /home/jaredt/.rvm/gems/ruby-2.7.5/bin/bundle:23:in `<main>'
web    |        1: from /home/jaredt/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
web    | /home/jaredt/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (1.17.3) required by your /home/jaredt/projects/maitre-d/Gemfile.lock. (Gem::GemNotFoundException)
web    | To update to the latest version installed on your system, run `bundle update --bundler`.
web    | To install the missing version, run `gem install bundler:1.17.3`
worker | Traceback (most recent call last):
worker |        4: from /home/jaredt/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `<main>'
worker |        3: from /home/jaredt/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `eval'
worker |        2: from /home/jaredt/.rvm/gems/ruby-2.7.5/bin/bundle:23:in `<main>'
worker |        1: from /home/jaredt/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
worker | /home/jaredt/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (1.17.3) required by your /home/jaredt/projects/maitre-d/Gemfile.lock. (Gem::GemNotFoundException)
worker | To update to the latest version installed on your system, run `bundle update --bundler`.
worker | To install the missing version, run `gem install bundler:1.17.3`
web    | Exited
worker | Exited

Notes

denys-chaikovskyi commented 2 years ago

Having similar issue. Getting error when running overmind start

Your Ruby version is 3.1.2, but your Gemfile specified 2.7.4

while having the current version pointed to 2.7.4

Seems like overmind use default instead of the current version of ruby.

Changing rvm default version to the needed version resolves the problem. @jared-thoughtbot, thanks for the suggested workaround.

DarthSim commented 2 years ago

Sorry, can't reproduce this :( Here's my shell output:

$ rvm list
=> ruby-2.7.6 [ arm64 ]
 * ruby-3.1.2 [ arm64 ]

# => - current
# =* - current && default
#  * - default

$ ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin21]

$ which ruby
/Users/darthsim/.rvm/rubies/ruby-2.7.6/bin/ruby

$ ./overmind s -f Procfile.test
system     | Tmux socket name: overmind-overmind-bNgYagaY6ln9AuE5FxSDy
system     | Tmux session ID: overmind
system     | Listening at ./.overmind.sock
ruby-v     | Started with pid 49572...
which-ruby | Started with pid 49573...
ruby-v     | ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin21]
which-ruby | /Users/darthsim/.rvm/rubies/ruby-2.7.6/bin/ruby
ruby-v     | Exited
which-ruby | Interrupting...
which-ruby | Exited

As you can see, the current Ruby version differs from the default one yet Overmind uses the current version as expected.

On a very basic level, Overmind doesn't do anything fancy but run tmux with commands from the Procfile. You can emulate the same behavior without Overmind involved:

  1. Create a test script: echo -e "#\!/bin/sh\nruby -v\nwhich ruby\nsleep 10" > ruby-test.sh
  2. Make it executable: chmod +x ruby-test.sh
  3. Run a new tmux server with it: tmux -L rubytest new ./ruby-test.sh

If it shows the wrong version too then Overmind is not a cause and you need to check your RVM installation.

jared-thoughtbot commented 2 years ago

Thanks for taking the time to investigate this!

I can confirm I'm seeing the wrong version when testing using your simplified script.

I am using fish shell so maybe there's something in the rvm config that's not right. I'll close this for now. Cheers!

denys-chaikovskyi commented 2 years ago

@jared-thoughtbot I also have this issue on the fish shell. Probably something with fish configs 🤔