Search

Enter a search word or two and press return to see the search results.

Who am I?

Hi, I’m Graeme and these are my notes, from my messy desk. I started this blog because Google proved to be more useful at finding content than anything else I’ve used.

So I started adding my own content in the hopes that Google would index it and allow me to find things again in the future.

It works.

You can find out more about me here, and you should follow me on Twitter here.

Keeping up

You can automatically receive new content here by subscribing to the “Blog RSS” (link below). This is the easiest way to keep up with what I write here.  See this BBC article for a good introduction on RSS and keeping up with the goings on of the Internet more easily.

« The Ruby Community | Main | My Ewgeco »
Monday
Mar152010

Updating the path everywhere on Ubuntu 09.10

Ubuntu is my Linux of choice. It has been for a long time. I’ve been a huge fan of Debian since the late ’90s — I was a Debian Developer stuck in the NM queue for a few years — but the release cycle was way too long for my tastes (which invariably meant I kept most of my systems running testing or unstable). So I switched to Ubuntu pretty early on.

I’m also a Ruby developer and, in particular, keep Ruby Enterprise Edition fed and cared for on my production servers. Every time I do a fresh install I have to remind myself how to make sure REE is always in the path and definitely in the path ahead of an accidental install of the stock Ruby on Ubuntu.

Here’s the list of things I’ve had to change this morning on Ubuntu 09.10 to make sure $PATH is set correctly everywhere:

  • /etc/environment, updating the PATH="..." line to read:

    PATH="/opt/ruby-enterprise/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

  • /etc/crontab, updating its PATH="..." line to read:

    PATH=/opt/ruby-enterprise/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

  • /etc/login.defs, updating the ENV_SUPATH and ENV_PATH lines to read:

    ENV_SUPATH PATH=/opt/ruby-enterprise/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV_PATH PATH=/opt/ruby-enterprise/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

  • /etc/sudoers, where I’ve had to add the following line to override the compiled-in default:

    Defaults secure_path = "/opt/ruby-enterprise/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"

That seems to have covered everything. The incantation for sudo was a bit of a bother to find (it being a built in default rather than configured in /etc), but with it, sudo irb now works, when it didn’t before. I haven’t changed the paths specified in init scripts as it seemed unnecessary.

For reference, the command I user to determine what might need changed was:

sudo find /etc -type f | xargs sudo grep 'PATH=' | grep -v /opt/ruby-enterprise

It produced a number of false positives, but was a good bet for figuring out the right ones.

So, have I missed anything? Have I changed things I shouldn’t have changed?

(And yes, I know, I should be using some sort of Configuration Management system to bootstrap everything I touch…)

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (4)

I believe /etc/environment is not a shell script and thus the quote characters should be unnecessary or maybe even invalid.

March 15, 2010 | Unregistered CommenterHongli Lai

Hongli, you're right, it's not a shell script, it's interpreted by the pam_env PAM module.

On the other hand, it's distributed by Ubuntu with the quotes, so I just left 'em in. :-)

March 16, 2010 | Registered CommenterGraeme Mathieson

That's a whole lot of work.

# mv /usr/bin/ruby /usr/bin/ruby1.8
# ln -s /path/to/ruby.ree /usr/bin/ruby

March 17, 2010 | Unregistered Commenterjosh

Josh, you're right it is a bit more work. Two reasons spring to mind:

* I never mess with the native packaging system. Your suggestion would be stomped over if there was a new upstream version of Ruby (eg a security update). I think there's a solution there with using dpkg-divert (on Debian and Ubuntu), but I haven't quite sussed it out yet.

* /path/to/ruby.ree isn't the only binary. With your solution, you're going to have to update the symlinks in /usr/bin every time you add or remove a gem, for example.

March 17, 2010 | Registered CommenterGraeme Mathieson
Comments for this entry have been disabled. Additional comments may not be added to this entry at this time.