9

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?

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
Linus
  • 2,799
  • 3
  • 29
  • 43

3 Answers3

15

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

Linus
  • 2,799
  • 3
  • 29
  • 43
  • 1
    I just tried to run this command but i get an error with --env `Unrecognized command line argument(s): '. --env' ( see: 'rvm usage' )`. Is it normal? – Yannick Schall Oct 29 '12 at 16:17
  • @YannickSchall I have used this command weekly until I upgraded RVM last week, and started to see this message. I think somehow support was dropped for this option but I cannot find any documentation about it. – jakeonrails Nov 06 '12 at 04:46
  • i've sorted the problem by adding a .powrc at the root of the projectwith the following code ` if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then source "$rvm_path/scripts/rvm" source ".rvmrc" fi` – Yannick Schall Nov 07 '12 at 13:25
2

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]

docwhat
  • 11,435
  • 6
  • 55
  • 54
Yannick Schall
  • 32,601
  • 6
  • 29
  • 42
1

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

Pavel Nikolov
  • 9,401
  • 5
  • 43
  • 55
  • Hi Pavel, is there a difference between `rvm env -- \`rvm current\`` and just `rvm env`? Simply doing `rvm env > .powenv` works fine for me. – Patrick Oscity May 12 '13 at 14:36
  • I haven't tried that. This is what I read somewhere and posted it since it is confirmed to work. But you can easily test and see if there is a difference in the output of both commands. – Pavel Nikolov May 14 '13 at 12:36
  • There was no difference for me but perhaps there may be a difference in certain circumstances. – Patrick Oscity May 14 '13 at 12:51