5

I use Pow and powify gem with my rails project.

Now I try to upgrade my ruby version (from 1.9.3 to 2.0.0, I use RVM)

When I switch ruby version, install all gem dependencies, I make sure that app works fine by running rails s and visiting localhost:3000

Previosly I browse my app by visiting http://my_app.dev with pow. After upgrade this url doesn't work due to error Bundler::RubyVersionMismatch: Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

What I tried:

  • recreate pow application
  • restart pow server
  • update pow server
  • kill pow server
  • google this error :)

This error still exists. By the way, I have another rails app, that uses ruby 2.0 initially and works with pow ok.

mikdiet
  • 9,859
  • 8
  • 59
  • 68

1 Answers1

8

Create an file called .powrc in your projects root directory. Copy and paste the content below to your file.

if [ -f "$rvm_path/scripts/rvm" ]; then
  source "$rvm_path/scripts/rvm"

  if [ -f ".rvmrc" ]; then
    source ".rvmrc"
  fi

  if [ -f ".ruby-version" ]; then
    rvm use `cat .ruby-version`
  fi

  if [ -f ".ruby-gemset" ]; then
    rvm gemset use --create `cat .ruby-gemset`
  fi
fi

This will look to your ruby environment files and select the correct version from it. If this won't work on your first try then make sure you have an .rvmrc or .ruby-version file in your root directory for the project.

And don't forget to touch tmp/restart.txt to restart your application.

Source: https://gist.github.com/nbibler/5307941

aross
  • 5,620
  • 1
  • 25
  • 32
  • I inattentively read pow manual :( I put such file in my `~` directory, but should in project directory. Thank you. – mikdiet Aug 25 '13 at 17:57
  • 1
    This doesn't work for me. Copied the above code to `.powrc` in my project directory and touched `tmp/restart.txt` but still getting the exact same error (upgrading from Ruby 2.2.0 to 2.2.1 using the line `ruby` in my Gemfile) – GMA Mar 16 '15 at 14:36
  • @GeorgeMillo try creating a file called '.ruby-version' in your project root directory with the content '2.2.1'. Then try again. – aross Mar 17 '15 at 16:54
  • I tried all this and it did not work. I tried rebooting, still not working. Waited a few minutes, still not working. Then I thought I would do something else and ran ```bundle exec rspec spec```, and then noticed that pow was now working. Not sure if it was the time delay or something to do with running the tests. – Obromios Aug 16 '16 at 06:08
  • Yah same here @Obromios , I restarted, changed all the things, reinstalled rvm, reinstalled bundler, everything *everything* says the correct Ruby, but I still got the fail message. Then after a couple hours it started working. But unfortunately I do have to switch between Rubies often enough that I likely shouldn't be using POW anymore. – Trip May 10 '17 at 13:07
  • Also this script doesn't work, and the one on RVM's website crashes the site as well with an error. – Trip May 10 '17 at 13:08
  • @Trip this may be outdated by now, feel free to sugest an edit on my answer if you manage to solve the problem using anything like this. – aross May 13 '17 at 12:14