overmind icon indicating copy to clipboard operation
overmind copied to clipboard

Overmind do not setup the same environment for all processes

Open Lomig opened this issue 3 years ago • 3 comments

Hi,

I discovered what I consider a very strange behaviour with Overmind, as it does not work properly on my computer whereas it does for my teammates.

We use it to serve locally a Rails project, and it does not seem to work properly for me (the main difference with my colleagues being that I'm using asdf to handle my Ruby executables) as it tries to use the global system version of Ruby instead of the managed one for all processes but the first one.

As an example:

My procfile:

debug: which gem
server: which gem
test: which gem
again: which gem
more: which gem
end: sleep 9999

The output:

Capture d’écran 2021-09-16 à 19 51 35

debug  | Started with pid 59135...
end    | Started with pid 59140...
server | Started with pid 59136...
test   | Started with pid 59137...
server | /usr/bin/gem                     #---> BAD
debug  | /Users/lomig/.asdf/shims/gem     #---> GOOD
more   | Started with pid 59139...
again  | Started with pid 59138...
test   | /usr/bin/gem                     #---> BAD
again  | /usr/bin/gem                     #---> BAD
more   | /usr/bin/gem                     #---> BAD
more   | Exited
again  | Exited
server | Exited
end    | Interrupting...
debug  | Exited
test   | Exited
end    | Exited

Does someone understand what happens here?

Thanks in advance.

Lomig avatar Sep 16 '21 17:09 Lomig

Hey @Lomig! Unfortunately, I don't have a proper solution for this :( asdf is the only versions manager that causes this issue, rbenv and friends work just fine. I'd try to add ~/.asdf/shims to your PATH, but no guarantees.

DarthSim avatar Feb 22 '22 12:02 DarthSim

@DarthSim I'm also running into this on rbenv currently, I can see that it's correctly loading both ruby and the path for the web process but for all the other processes it loads a completely different path despite loading the same user and shell.

system  | Listening at ./.overmind.sock
webpack | Started with pid 62975...
web     | Started with pid 62974...
worker  | Started with pid 62976...
web     | /Users/ryanmacgillivray/.rbenv/shims/ruby
web     | /opt/homebrew/bin/zsh
web     | /Users/ryanmacgillivray/.rbenv/shims:/Users/ryanmacgillivray/.pyenv/shims:/Users/ryanmacgillivray/.yarn/bin:/Users/ryanmacgillivray/.config/yarn/global/node_modules/.bin:/Users/ryanmacgillivray/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/Users/ryanmacgillivray/.rbenv/shims:/Users/ryanmacgillivray/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ryanmacgillivray/.rbenv/shims:/Users/ryanmacgillivray/.rbenv/shims/ruby:/Users/ryanmacgillivray/.pyenv/shims:/Users/ryanmacgillivray/.yarn/bin:/Users/ryanmacgillivray/.config/yarn/global/node_modules/.bin:/Users/ryanmacgillivray/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/ryanmacgillivray/.config/nvim/dein_plugins/repos/github.com/junegunn/fzf/bin
webpack | /usr/bin/ruby
webpack | /opt/homebrew/bin/zsh
webpack | /opt/homebrew/bin:/usr/local/bin:/bin:/usr/bin
worker  | /usr/bin/ruby
worker  | /opt/homebrew/bin/zsh
worker  | /opt/homebrew/bin:/usr/local/bin:/bin:/usr/bin

RyanMacG avatar May 16 '22 13:05 RyanMacG

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 gem\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 \; neww ./ruby-test.sh

If it shows the wrong path too then Overmind is not a cause and you need to check your shell config.

DarthSim avatar Jun 28 '22 11:06 DarthSim