DarthSim / overmind

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

Overmind attempts to run processes using wrong version of ruby? #61

Closed efigarolam closed 4 years ago

efigarolam commented 4 years ago

Hi! I'd like to report an issue that I'm having and it stops me from using overmind. I have used foreman for years and I heard of overmind a couple of months ago.

I use tmux and fish shell. Here is the output I'm seeing when attempting to run overmind start

system  | Tmux socket name: overmind-project-Lm39zBQtTL86k07DQvPKu-
system  | Tmux session ID: project
system  | Listening at /Users/efigarola/workspace/project/.overmind.sock
web     | Started with pid 26814...
web     | /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler (LoadError)
web     |       from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
web     |       from /Users/efigarola/workspace/project/bin/spring:9:in `<top (required)>'
web     |       from bin/rails:5:in `load'
web     |       from bin/rails:5:in `<main>'
web     | Exited

Here are some details of my machine:

Procfile:

web: bin/rails s -p $PORT
redis: redis-server
sidekiq: bundle exec sidekiq -q default -q mailers
webpack: bin/webpack-dev-server

Gem ENV outside tmux:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.6
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Users/efigarola/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
  - USER INSTALLATION DIRECTORY: /Users/efigarola/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /Users/efigarola/.rbenv/versions/2.5.1/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/efigarola/.rbenv/versions/2.5.1/bin
  - SPEC CACHE DIRECTORY: /Users/efigarola/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/efigarola/.rbenv/versions/2.5.1/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-18
  - GEM PATHS:
     - /Users/efigarola/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
     - /Users/efigarola/.gem/ruby/2.5.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/efigarola/.rbenv/versions/2.5.1/bin
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/efigarola/.rbenv/shims
     - /Users/efigarola/.rbenv/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin

Gem env inside tmux:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.6
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Users/efigarola/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
  - USER INSTALLATION DIRECTORY: /Users/efigarola/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /Users/efigarola/.rbenv/versions/2.5.1/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/efigarola/.rbenv/versions/2.5.1/bin
  - SPEC CACHE DIRECTORY: /Users/efigarola/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/efigarola/.rbenv/versions/2.5.1/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-18
  - GEM PATHS:
     - /Users/efigarola/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
     - /Users/efigarola/.gem/ruby/2.5.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/efigarola/.rbenv/versions/2.5.1/bin
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/efigarola/.rbenv/shims
     - /Users/efigarola/.rbenv/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/efigarola/.rbenv/shims

I noticed in the error shown by overmind that it attempts to use ruby 2.3 which is not the version I'm using in my project, I use rbenv for managing my ruby environment and both the local and global version of ruby are 2.5.1

Any ideas on what I'm missing? foreman works and running tmux new bin/rails s also works. I have really liked what overmind has to offer and that's why I decided to migrate from foreman

DarthSim commented 4 years ago

That's pretty strange since Overmind doesn't do any fancy stuff with launching the processes. Let's do some debugging. Add the following process to your Procfile and give me the result please:

debug: echo "SHELL=$SHELL" && which ruby && ruby -v && which rbenv && rbenv versions && sleep 9999

I suspect that the problem is that fish doesn't set as your login shell which is used by Overmind to launch processes.

efigarolam commented 4 years ago

Hello @DarthSim thanks for taking a look on this, here is the output for the debug process

debug   | SHELL=/usr/local/bin/fish
debug   | /usr/bin/ruby
debug   | ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
debug   | /usr/local/bin/rbenv
debug   |   system
debug   |   2.5.0
debug   | Exited

Let me know if I need to help you with anything else.

DarthSim commented 4 years ago

Well, it looks weird because everything is ok except of ruby version. Could you also show me rbenv versions output outside of Overmind?

efigarolam commented 4 years ago

This is what I see when I run rbenv versions within my project dir, I see the same within and out of tmux

  system
  2.5.0
* 2.5.1 (set by /Users/efigarola/workspace/project/.ruby-version)
  2.6.2
  2.6.4
  2.6.5
DarthSim commented 4 years ago

Ok, that's interesting. So, rbenv doesn't see the whole list of installed Rubies inside Overmind. Could you add rbenv root to the debug process right before sleep and show me the output? Also, run it outside of Overmind and show me the output.

efigarolam commented 4 years ago

Cool, here is the result of rbenv root outside overmind:

/Users/efigarola/.rbenv

Here is the debug process of overmind:

webpack | Started with pid 77401...
debug   | Started with pid 77399...
web     | Started with pid 77400...
debug   | SHELL=/usr/local/bin/fish
debug   | /usr/bin/ruby
debug   | ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
debug   | /usr/local/bin/rbenv
debug   |   system
debug   |   2.5.0
debug   | * 2.5.1 (set by /Users/efigarola/workspace/project/.ruby-version)
debug   |   2.6.2
debug   |   2.6.4
debug   |   2.6.5
debug   | /Users/efigarola/.rbenv
webpack | Your Ruby version is 2.6.3, but your Gemfile specified 2.5.1
webpack | Exited
web     | Your Ruby version is 2.6.3, but your Gemfile specified 2.5.1
debug   | Interrupting...
web     | Exited
debug   | Exited
DarthSim commented 4 years ago

Wait a sec, so rbenv sees all the Rubis inside Overmind, and it successfully detects the currectly selected version. This means that the problem is $PATH. Could you show me your $PATH inside and outside of Overmind?

efigarolam commented 4 years ago

I noticed that, but it behaves randomly, sometimes it shows them, sometimes it don't, I think it depends in how quickly the other processes fails.

Here is the output of $PATH within overmind:

debug   | PATH=/Users/efigarola/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/Users/efigarola/.rbenv/shims

Here is the output outside overmind:

echo "PATH=$PATH"

PATH=/Users/efigarola/.rbenv/shims:/Users/efigarola/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/Users/efigarola/.rbenv/shims

Looks like the difference is at the beginning /Users/efigarola/.rbenv/shims ...

DarthSim commented 4 years ago

I think it depends in how quickly the other processes fails

Yeah, it makes sense.

It's left to determine how you add /Users/efigarola/.rbenv/shims to your PATH and how you initialize rbenv.

I personally use oh-my-fish with rbenv plugin, and I have no problems like this.

efigarolam commented 4 years ago

@DarthSim ok, I just installed rbenv plugin with oh-my-fish, and now it works. I'm sorry if this should have been obvious, I'm new to fish, I was not aware of the existence of that rbenv plugin

Thanks for your support on this, do you want me to write a note on the README or any other place about this?

DarthSim commented 4 years ago

Was glad to help! 👍

I'll add the known issues section to README.

efigarolam commented 4 years ago

Great, thank you again, I will close this!