Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pow does not change ruby version after project upgrade

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.

like image 626
mikdiet Avatar asked Aug 25 '13 14:08

mikdiet


1 Answers

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

like image 104
aross Avatar answered Sep 19 '22 09:09

aross