-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 #400
Comments
It's not system ruby since the stack trace comes from:
which clearly indicates that you're running 2.0. I would rather believe this is a bug with Bundler's version check. |
Ok, thanks. |
They are saying:
|
OK, let us see your
|
$ rbenv which bundle bundle install does the usual Using x (x.x.x) stuff. The command i'm running is: $ bundle exec rake prod_data The part of the rake task mentioned in the stack trace (see below) is:
$ ls ~/.rbenv/plugins/ I only had ruby-build when I first had this problem - I installed rbenv use to see what happened if I manually selected ruby-2.0.0 instead of letting .ruby-version in my project directory switch it. I've just tried running those two hooks commands and get the same error:
|
It seems like everything is in order, from your end, but that the rake task spawns a Ruby subprocess somewhere with system ruby ( Does any executable you start has a shebang |
Thanks for the reply - that was the theory I ended up at too. I'm just going to go through the task and see if I can see/debug what the problem is. Thanks, Ian |
When in doubt, check the PATH before shelling out. $stderr.puts ENV["PATH"] |
Found the problem.... i'm shelling out to the heroku command in the rake task - which comes from Heroku Toolbelt. However, at the top of /usr/bin/heroku is this shebang:
and sure enough:
So that makes sense - except why is bundler complaining? - where does bundler come in when a rake task is calling that executable? What would you advise as the best fix? - I don't want to change /usr/bin/heroku as that's written by their toolbelt installer and will get upgraded from time to time. Do I need to prefix the call in the rake task with something to send it through rbenv/bundler? (although some people here use rvm on mac and some rbenv on vagrant, so actually I wouldn't want to hard code rbenv...is there a way of executing that in a proper shell which has read the profile?) I'm just using backticks ( Thanks, Ian |
@ichilton If you have a Rake task that is forking off a subprocess to run a command like In Bundler::Runtime#setup_environment, Bundler sets some environment variables, the most important being
So what do you do when you want to bust out of Bundler's bubble for subprocesses? Nuke some # Rakefile
task :freedom do
Bundler.with_clean_env { sh "heroku" }
end That should help the embedded/vendored Ruby in the Heroku Toolbelt to be invoked in a less tainted way. Hope this helps, this is thorny stuff! |
Thank you Fletcher! - i've actually just come across the same thing here: rubygems/bundler#2355 so am going to try that now! |
@fnichol Pretty epic answer. Thanks! Closing this since it's not a bug. |
Just to confirm this, changing the shell calls to the following fixed the problem: Thanks guys. |
Thanks! |
@fnichol Thanks! 👍 |
Thank you @fnichol |
@fnichol this was awesome to come across. Yet another thanks! |
Thanks @fnichol, this helped me solve a related problem. Basically that I should never run |
@fnichol exactly what I was looking for. Thanks! |
Upgrade Ruby versionLogin as root Install needed packages
Download appropriate ruby version https://www.ruby-lang.org/en/downloads/ Unpack downloaded package Compile from source |
I'm trying to run a rake task on a rails app, and am getting this error:
As you can see from the paths in the error though, I am running 2.0.0:
$ ruby -v
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
$ bundle -v
Bundler version 1.3.5
$ gem env
RubyGems Environment:
I tried doing rbenv global 2.0.0-p195, but that didn't help. Looks like it might be trying to use system ruby instead of rbenv for some reason?
Raised an issue with bundler: rubygems/bundler#2489 but it seems to be an rbenv issue.
rake is a rbenv shim at: ~/.rbenv/shims/rake
Thanks,
Ian
The text was updated successfully, but these errors were encountered: