From: Iain Barnett Date: 2010-09-03T22:47:03+09:00 Subject: Re: load path On 3 Sep 2010, at 09:14, Brian Candler wrote: > Iain Barnett wrote: >> Is there somewhere I can just add the path hardcoded? > > At the top of your app you could do > > $LOAD_PATH.unshift ENV['GEM_HOME'] unless $LOAD_PATH.include? > ENV['GEM_HOME'] > > for a nasty workaround. I shudder less at this > > As for how $LOAD_PATH is built: well, it's in ruby.c (look for incpush > and push_include), but the bits you're looking at are probably added by > rubygems. than at the thought of dealing with C :) On 3 Sep 2010, at 02:38, Ryan Davis wrote: > > 502 % grep -A1 ryand /etc/sudoers > # Added by ryand: > Defaults env_keep += "GEM_PATH GEM_HOME" > > You need to pay attention to where you put that. It HAS to be after the reset_env line or it obviously won't work. I don't have a reset line, but here's my sudoers. # sudoers file. # # This file MUST be edited with the 'visudo' command as root. # # See the sudoers man page for the details on how to write a sudoers file. # # Host alias specification # User alias specification # Cmnd alias specification # Defaults specification Defaults env_keep += "GEM_PATH GEM_HOME" # Runas alias specification # User privilege specification root ALL=(ALL) ALL %admin ALL=(ALL) ALL %iainuser ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL # Samples # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom # %users localhost=/sbin/shutdown -h now > >> Last login: Thu Sep 2 18:34:01 on ttys002 >> 501 % env | grep GEM >> GEM_PATH=/Library/Ruby/Gems/1.8 >> 502 % sudo bash >> 501 % env | grep GEM >> GEM_PATH=/Library/Ruby/Gems/1.8 > > > btw... are you sure you've exported your env vars? I used the method Brian Candler suggested in the other mail, but I get the same with the one you've used here: sudo zsh env (blah blah blah...) GEM_HOME=/Users/iainuser/.gems GEM_PATH=/Users/iainuser/.gems sh -c 'echo $GEM_HOME' /Users/iainuser/.gems sudo sh -c 'echo $GEM_HOME' /Users/iainuser/.gems sudo sh -c 'env' (blah blah blah...) GEM_HOME=/Users/iainuser/.gems HOME=/Users/iainuser GEM_PATH=/Users/iainuser/.gems Here's a relevant portion of my zprofile, with recent additions included: export RUBY_PLATFORM=darwin export PLATFORM="$RUBY_PLATFORM" export RUBY_VERSION=1.9 export GEM_HOME="$HOME/.gems" export RUBYLIB="$GEM_HOME" export GEM_PATH="$GEM_HOME" export RUBYOPT=rubygems > >> ... >> >> Is there somewhere I can just add the path hardcoded? I don't really care about configurability, I'm not moving my gems anywhere else soon. > > Fix it correctly or don't fix it at all. Anything else is just a headache delayed. > I agree, but sometimes you just want a headache tablet. Or anything that comes on prescription, I hear that's what all the top celebrities are doing nowadays. Except for Paris Hilton. Not sure if she counts as a top celebrity though. If she'd been caught with several prescriptions I might change my mind about her... Regards, Iain