Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am ruby1.8 user, as well as gem; it's library manager system.

gem is able to install binaries, like rails and bundle.

But I could not get access for this guys until I added this line to my .bashrc :

export PATH=$PATH:/var/lib/gems/1.8/bin

So now, the binaries work, but not if I use sudo first!

fabianops ~/workspace3/peded $ sudo rails s thin -p80 -blocalhost --debugger
[sudo] password for fabianops: 
sudo: rails: command not found

I need sudo to bind port 80, how can I use sudo rails .. ?

Never had that issue with Ubuntu 10.

update: I guess, what I want is for these PATH to be available system wide.

share|improve this question

By default sudo resets environment to minimal set of variables. See 'SECURITY NOTES' section in man sudo. To preserve you environment variables you could use sudo -E (or see env_reset option in man sudo). Also, to debug, you could try comparing output of sudo env/env and sudo gem env/gem env.

share|improve this answer
  1. sudo su -
  2. rails s thin -p80 -blocalhost --debugger

Determine the actual error. Or explicitly pass the path to rails so the sudo cmd.

share|improve this answer
    
Did that, and got: The program 'rails' is currently not installed. You can install it by typing: ... – Fabiano PS May 26 '11 at 19:51
    
Does whereis rails while elevated locate things? How did you install rails? Basically it seems like your path isn't right. Rather than pollute the root account and/or other accounts, it's probably better to use the explicit path to rails when you run sudo. YMMV. – OldTroll May 26 '11 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .