6

I am using a Mac with Pow, Ruby, Rails and a bunch of useful gems. I recently got this error whenever I try to open my app.

Bundler::RubyVersionMismatch: Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

I understand the error, but I can't find why it is not using the proper version here.

Some information that can be useful:

Stack Trace

Bundler::RubyVersionMismatch: Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
~/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/definition.rb:361:in `validate_ruby!'
~/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:116:in `setup'
~/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
~/Dropbox/Documents/project/Sites/project-profile/config.ru:3:in `block in <main>'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/Dropbox/Documents/project/Sites/project-profile/config.ru:1:in `new'
~/Dropbox/Documents/project/Sites/project-profile/config.ru:1:in `<main>'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:50:in `eval'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:50:in `load_config'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:43:in `initialize'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:13:in `new'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:13:in `run'
~/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/bin/nack_worker:4:in `<main>'

RVM & Ruby version

$> ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
$> rvm use 
Using /Users/Alex/.rvm/gems/ruby-2.0.0-p247

Any idea what I am missing here? Thanks!

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Liyali
  • 5,643
  • 2
  • 26
  • 40
  • 1
    Do you have any .ruby-version files in your project, and you might need to paste your Gemfile too, if you have .ruby-version it is probably changing the version of ruby as you switch into the folder – bjhaid Nov 25 '13 at 18:13
  • 1
    Are you using both rbenv and rvm at the same time? – toro2k Nov 25 '13 at 18:33
  • I am using RVM but I also have rbenv installed on my system, printing `rbenv versions` result was a bit confusing, sorry about that. – Liyali Nov 26 '13 at 10:20

3 Answers3

14

I finally found out the solution in RVM documentation:

Pow has removed automated detection of rvm, here is how it can be restored by creating .powenv in the root of the project, according to Pow docs it should not be checked in to source control (unless all team members agree on that).

These lines must be added to the .powenv file at the root of your project. Then after restarting the server everything worked like a charm!

# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi

# load environment of current project ruby
if
  [ -n "${rvm_path:-}" ] &&
  [ -x "${rvm_path:-}/bin/rvm" ] &&
  rvm_project_environment=`"${rvm_path:-}/bin/rvm" . do rvm env --path 2>/dev/null` &&
  [ -n "${rvm_project_environment:-}" ] &&
  [ -s "${rvm_project_environment:-}" ]
then
  echo "RVM loading: ${rvm_project_environment:-}"
  \. "${rvm_project_environment:-}"
else
  echo "RVM project not found at: $PWD"
fi
Liyali
  • 5,643
  • 2
  • 26
  • 40
  • Where exactly is the .powenv file? I can't seem to find it. – idude Mar 30 '14 at 22:35
  • 1
    You have to create it by yourself: `touch .powenv` at the root of the project directory. Then you can edit it with any text editor. Note that dot-files (filenames starting with a ".") are hidden by default on unix-like OS. – Liyali Mar 31 '14 at 08:17
  • This fails with `.powrc' failed to load: true &&` – Trip May 10 '17 at 13:05
  • @Trip could it be related to https://stackoverflow.com/questions/14435735/cryptic-error-when-trying-to-run-pow? – Liyali Jun 01 '17 at 08:47
0

Maybe check version in .rvmrc in your project root folder. If you haven't got one create it. Move to your project folder in terminal and type in rvm --create --rvmrc 2.0.0-p247@yourgemsetname. After you have to direct to you parent folder and back to your project folder. Latest versions of rvm use .ruby_version instead of .rvmrc.

0

touch .ruby-version

add ruby-2.0.0

Try again. Worked for me with Pow + RVM + ruby-2.2.1

suzumakes
  • 760
  • 3
  • 12