Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pow, RVM and ZSH not working together

I'm trying to get Octopress (http://octopress.org/) working, but I'm having some issues. I'm using POW (http://pow.cx/) and it seems to not load the correct Ruby version for me (using RVM).

It always uses the RVM default ruby version and not the one specified in .rvmrc. My default Ruby version in RVM is: ruby-1.9.3-p125.

In my .rvmrc file I have this: rvm use 1.9.2 I get this error in the browser when visiting my site:

LoadError: cannot load such file -- bundler/setup
~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
~/Sites/Lejnus/lejnus/config.ru:1:in `block in <main>'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/Sites/Lejnus/lejnus/config.ru:1:in `new'
~/Sites/Lejnus/lejnus/config.ru:1:in `<main>'
~/Library/Application     Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:50:in `eval'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:50:in `load_config'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:43:in `initialize'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:13:in `new'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:13:in `run'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/bin/nack_worker:4:in `<main>'

Why is it using 1.9.3-p125 when 1.9.2 is specified in my .rvmrc file? If I set 1.9.2 as default it works of course...

Isn't it supposed to do this magic for me and use the correct ruby versions?

like image 351
Linus Avatar asked Apr 14 '12 15:04

Linus


3 Answers

Ok, seems like POW is moving away from RVM.

I needed to run this in my projects root to get it working: rvm env . -- --env > .powenv

like image 115
Linus Avatar answered Sep 20 '22 12:09

Linus


i've sorted the problem by adding a .powrc at the root of the project with the following code

if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
  source "$rvm_path/scripts/rvm"
  source ".rvmrc"
fi

[Edited to add: This is recommended in the Pow documentation]

like image 31
Yannick Schall Avatar answered Sep 23 '22 12:09

Yannick Schall


This is what solved the problem for me:

rvm env -- `rvm current` > .powenv

You can also create a rvm hook (as commented here) for switching the .powenv automatically when you change the current ruby env:

# ~/.rvm/hooks/after_use_update_powrc
for file in `ls ~/.pow/` ; do
  POW_LINK_TARGET=`readlink ~/.pow/$file`

  if [ `pwd` = $POW_LINK_TARGET ]; then
    rvm env -- ``rvm current`` > .powenv
  fi
done

Don't forget to make it executable:

chmod +x ~/.rvm/hooks/after_use_update_powrc

like image 1
Pavel Nikolov Avatar answered Sep 24 '22 12:09

Pavel Nikolov