🕷 zenspider.com

by ryan davis

Looking for the Ruby Quickref?

GEM_PATH, rubygems, and you

Published 2009-08-24 @ 16:10

Tagged thoughts

On OSX, I have GEM_PATH set in my environment to stop using (or even seeing) apple installed gems which inevitably grow stale. I do that via:

export GEM_PATH=`gem env home`

This works pretty well, except for gem clean which always bitches about rails and libxml-ruby and a bunch of other crap I don’t care about. I couldn’t figure out why gem list was fine but gem clean was seeing stuff it shouldn’t be able to see.

I figgered it out!

See, apple added a bunch of extra safeguards to the default sudo configuration:

# Defaults specification
Defaults        env_reset
Defaults        env_keep += "BLOCKSIZE"
# ...
Defaults        env_keep += "EDITOR VISUAL"

This is actually pretty cool when you think about it. Your environment is clean(er)ly scrubbed whenever you’re acting as root. So, to fix this, you run sudo visudo and add this to the env_keep section:

# Added by ryand:
Defaults        env_keep += "GEM_PATH GEM_HOME"