sstephenson/rbenv — Issue #120: Setting RBENV_DIR from within Ruby script
Author: malditogeek
Created: 2011-10-13 17:16:53+00:00
State: open

I'm trying to run bundler for a project that runs on a different Ruby version, so from the command line, rbenv just work as advertised:

```
~ $> ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
~ $> RBENV_DIR=/Users/mauro/src/sample/ bundle check --gemfile /Users/mauro/src/sample/Gemfile
[:RUBY_VERSION, "1.8.7"]
The Gemfile's dependencies are satisfied
```

But if try to run the same command from within a Ruby script, looks like RBENV_DIR is ignored. Not sure if this is related with rbenv itself or is a common issue when working with environment variables and system commands:

```
>> ENV['RBENV_DIR'] = '/Users/mauro/src/sample/'
=> "/Users/mauro/src/sample/"
>> `bundle check --gemfile /Users/mauro/src/sample/Gemfile`
=> "[:RUBY_VERSION, \"1.9.2\"]\nThe Gemfile's dependencies are satisfied\n"
```
I tried with system, backticks and %x. None of them seems to work.

Is there a workaround for this?