format internet:

…please wait (42% completed)…

sudo: rake: command not found

Posted by javier ramirez on July 6, 2009

I hate it when it happens, don’t you?

And it’s not only rake, but some other utilities too.

Bottom line is, in Ubuntu sudo is by default set to use a secure path. You can change the secure path if you are compiling from source, but we are talking Ubuntu here, the windows for the rest of us, so you get what your package says you get and that’s fine.

There are a couple of good solutions (other than switching to gentoo or slackware ;) )

If you want to use always the same PATH as you are using in your environment, you can just set an alias to sudo and make it set the PATH every time you are invoking it.

alias sudo=”sudo env PATH=$PATH”

It’s safe enough, but notice every time you are using sudo, you will be setting the environment to that of the calling user. Do your maths and reckon whether you are comfortable with that or not.

The option I chose is a bit pickier, making a link to the rake executable from /usr/local/bin, which is one of the secure paths.

sudo ln -s `which rake` /usr/local/bin/

Either way, your problem is solved. Now go save the world! You’re welcome ;)

3 Responses to “sudo: rake: command not found”

  1. Keith said

    Thankyou ever so much for posting this. I still don’t get quite how that symbolic link actually works, but it definitely fixes the problem!!

  2. Ian said

    The alias command works well.
    Another option is to chmod a directory to allow execution for users.

  3. Dean said

    Thanks for this. I had issues with both gem and ruby, so created symbolic links for all of the ruby bin executables…
    find /home/dean/.rvm/rubies/ruby-1.9.3-p0/bin/ -name “*” -exec sudo ln -s {} /usr/local/bin \;
    this makes an extra “bin” link which needs deleting: (it make a symlink of the “.” directory)
    sudo rm /usr/local/bin/bin

    now it works!
    sudo gem install mysql
    Fetching: mysql-2.8.1.gem (100%)
    Building native extensions. This could take a while…
    Successfully installed mysql-2.8.1
    1 gem installed
    Installing ri documentation for mysql-2.8.1…
    Installing RDoc documentation for mysql-2.8.1…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: