You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two versions of ruby installed, 1.9.3 and 2.1.5. master.rb is started with bundle exec, and it declares "ruby '2.1.5'" in its gemfile, and has a .ruby-version file with contents '2.1.5'.
master.rb switches to the dir that houses slave.rb, which is still running 1.9.3(p-484). It has
a gemfile entry of "ruby '1.9.3'" and .ruby-version file with contents '1.9.3'.
If I try running bundle exec ruby --version from master.rb in slave.rb's dir, it complains that the Gemfile specifies 1.9.3, but it's running 2.1.5. I reproduced this with this small two-file example:
master.sh:
#!/bin/bash
export RBENV_VERSION=2.1.5
echo "Ruby in shell script: `ruby --version`"
echo "Now shell out, hoping for 1.9.3:"
ruby slave.rb
and slave.rb:
system("bundle exec ruby --version")
The output is:
Ruby in shell script: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
Now shell out, hoping for 1.9.3:
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
While in my system I launch the master under bundle exec, I don't have to here to reproduce
the problem. It seems that just setting RBENV_VERSION and then running rbenv/libexec pushes
the 2.1.5 path to the top of the PATH as a sort of optimization, and I'm stuck with it when I try
to spawn children. I even passed a cleaned path as the first arg to system in slave.rb, but it didn't have an effect.
Is there a way to do this, or should we migrate all our components to the same version?
The text was updated successfully, but these errors were encountered:
I think I just ran into this bug. I think this is because the $RBENV_DIR env var is being set from the top-level ruby and leaking down into the subcommands, even if $RBENV_VERSION is being changed.
Can you try prepending rbenv shell --unset; RBENV_DIR= to the subcommand?
UPDATE: Both $RBENV_VERSION and $RBENV_DIR are leaking to children processes. Even though you can unset the $RBENV_VERSION using rbenv shell --unset, you still need to manually clear out $RBENV_DIR.
I've also been bitten by this. This seems to be because rbenv works to keep the Ruby version the same. This is done by prepending the path of the selected Ruby to PATH as seen here.
Using Bundler 1.6.2
I have two versions of ruby installed, 1.9.3 and 2.1.5. master.rb is started with bundle exec, and it declares "ruby '2.1.5'" in its gemfile, and has a .ruby-version file with contents '2.1.5'.
master.rb switches to the dir that houses slave.rb, which is still running 1.9.3(p-484). It has
a gemfile entry of "ruby '1.9.3'" and .ruby-version file with contents '1.9.3'.
If I try running
bundle exec ruby --version
from master.rb in slave.rb's dir, it complains that the Gemfile specifies 1.9.3, but it's running 2.1.5. I reproduced this with this small two-file example:master.sh
:and
slave.rb
:The output is:
While in my system I launch the master under bundle exec, I don't have to here to reproduce
the problem. It seems that just setting
RBENV_VERSION
and then runningrbenv/libexec
pushesthe 2.1.5 path to the top of the
PATH
as a sort of optimization, and I'm stuck with it when I tryto spawn children. I even passed a cleaned path as the first arg to system in
slave.rb
, but it didn't have an effect.Is there a way to do this, or should we migrate all our components to the same version?
The text was updated successfully, but these errors were encountered: