Skip to content

Instantly share code, notes, and snippets.

@brookr
Forked from derekharmel/gist:2399684
Created April 25, 2012 21:34
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save brookr/2493622 to your computer and use it in GitHub Desktop.
Save brookr/2493622 to your computer and use it in GitHub Desktop.
How to fix pow not using the correct gemset
# From the project root
rvm env -- `rvm current` >> .powenv
@brookr
Copy link
Author

brookr commented Apr 25, 2012

Looks like all I really needed in my .powenv from the full rvm environment is:

export GEM_HOME='/Users/brookr/.rvm/gems/ruby-1.9.3-head@gemset_name'
export MY_RUBY_HOME='/Users/brookr/.rvm/rubies/ruby-1.9.3-head'

Anyone know a way to make that more generic? Embedding whoami on the right of the assignment does not work.

@gmanley
Copy link

gmanley commented May 9, 2012

The following should work:

export GEM_HOME="$rvm_path/gems/ruby-1.9.3-head@gemset_name"
export MY_RUBY_HOME="$rvm_path/rubies/ruby-1.9.3-head"

I think the reason you couldn't use whoami was because you are using single quotes which will use the literal string.

@brookr
Copy link
Author

brookr commented May 9, 2012

D'oh, of course! I was focusing on working with the output of rvm current, didn't even think about changing the quotes. Using $rvm_path is even better.

Much appreciated!

@denro
Copy link

denro commented May 29, 2012

I used this to create a RVM-hook for switching the .powenv after each rvm use change:

# ~/.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

Making it executable:

chmod +x ~/.rvm/hooks/after_use_update_powrc

@DoppioJP
Copy link

@denro, your solution worked perfectly. Just one needs to remember to not have any real folder in ~/.pow directory, otherwise shell error will appear:

-bash: [: /Users/me/.rvm/hooks: unary operator expected

Dec 23, 2015
NOTE: I ran across the above error because I put into ~/.pow directory a real folder. But now in the current rvm version 1.26.11 the above hook is no longer needed.

@davidhq
Copy link

davidhq commented May 12, 2013

is there even simpler way? will the next pow release support .ruby-gemset?

@apolzon
Copy link

apolzon commented May 24, 2013

At the very least, pow should detect the .ruby-gemset file and issue a warning like it does for a detected .rvmrc file...

@seanlinsley
Copy link

Thanks for the script @denro, but it's unfortunate that it's still necessary today.

@neohunter
Copy link

so pow dont use the ruby-gemset YET?

@jetsgit
Copy link

jetsgit commented Feb 3, 2016

Pow is using

.ruby-gemset   .ruby-version

as of Pow v.0.5.0

@denro solution is still necessary, tho

@kWhittington
Copy link

@jetsgit, do you still need to configure a .powrc to accept the .ruby-gemset and .ruby-version files correctly? Like in this gist: https://gist.github.com/nbibler/5307941 ?

@jetsgit
Copy link

jetsgit commented Mar 9, 2016

@kWhittington, ---I discovered the solution @denro mentioned is still necessary and still works great.

@jetsgit
Copy link

jetsgit commented Oct 5, 2016

If you wish to debug using POW and pry-remote, you can do the following:
echo 3000 > ~/.pow/yourapp

However, that will cause an annoying error, e.g.:

/Users/jet/.rvm/hooks/after_use_update_powrc:6: parse error: condition expected: /Users/jet/Rails_Projects/puget-sound-salmon

To fix that, modify the bash script to the following, which will only exec on symlinks:

# ~/.rvm/hooks/after_use_update_powrc

for file in `ls ~/.pow/` ; do
  POW_LINK_TARGET=`readlink ~/.pow/$file`
  if [ -L "$POW_LINK_TARGET" ]; then
    if [ `pwd` = $POW_LINK_TARGET  ]; then 
      rvm env -- ``rvm current`` > .powenv
    fi
  fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment