Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Jun 28, 2008

Determine What Version of Ubuntu You're Running?

The best way to determine the version of an Ubuntu (or any LSB compliant) distribution is to use the lsb-release command:

$ sudo apt-get install lsb-release
$ lsb_release -a
# Distributor ID: Ubuntu
# Description: Ubuntu 8.04
# Release: 8.04
# Codename: hardy

Apr 5, 2008

NetBeans on Ubuntu

I'm usually a hardcore Vim fan but I've started to use NetBeans for my Ruby work. It's a fairly typical install but the one quirk is that $JAVAHOME has to be defined for the installer and Ubuntu's JDK package doesn't set it.

That's easily remedied though; download NetBeans, install the JDK and pass --javahome to the installer as a command line option.

#> netbeans-6.0.1-ml-linux.sh --java-home /usr/lib/jvm/java-6-sun

Ubuntu 8.04 "Hardy Heron"

The new Ubuntu release, 8.04 "Hardy Heron", is nearly out so I thought I'd take a few minutes to do a fresh 'from scratch' install on to my laptop, a Dell Latitude D830, this weekend. I was pleasently suprised that almost everything worked exactly as expected out of the box, including; wireless networking, dual head monitor support, suspend, hibernate, compiz, etc....

There was one small but very critical change I had to make. It appears that the ACPI hard drive load/unload bug has still not been fixed. It's critically important that you apply this work around unless you want your hard drive to die prematurely.

There was one other non-critical change I made. I didn't dig into the issue to understand it but for what ever reason the default ALSA settings don't support the audio pass through in the docking station. Fortunately the fix is extremely simple. You just need to install the "Gnome Alsa Mixer" and select the IEC958 check box.

#> sudo apt-get install gnome-alsamixer



I've been running Ubuntu on this laptop since the 7.04 Feisty Fawn release and this is by far the smoothest install yet. In the past I've been reluctant to declare Ubuntu's desktop experience to be better than Windows but I think I'm finally convinced.

Setting CFLAGS

It turns out the gento-wiki has a great page indicating which GCC -march flag should be set for which CPUs. To determine which CPU you have, run the following at a command prompt:

#> cat /proc/cpuinfo

It will yield a page of output. The first few lines of output from my laptop are below:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz
stepping : 10

The part you're interested in is the 'cpu family' and 'model'. Once you know those find the corresponding entries on http://gentoo-wiki.com/Safe_Cflags. Then create an entry in $HOME/.bashrc file that looks something like this:
CFLAGS="-march=prescott -O3"
CXXFLAGS="${CFLAGS}"
export CFLAGS CXXFLAGS

Of course substitute the -march value for the one you found on the wiki.

Dec 27, 2007

Multiple Versions of Ruby On Ubuntu

edit: moved install from $HOME to /opt.

With Ruby 1.9 out there's the obvious possiblitity some people will want to run multiple versions of Ruby so I thought I'd share this.

My goal is to have the Ubuntu Ruby packages installed along side the most current releases of 1.8 and 1.9

First I'll install using apt to create my default ruby install.

$> sudo apt-get install ruby irb ri rdoc libruby-extras rubygems ruby1.8-dev
$> sudo gem install rake

Next I'll install the most current release packages of 1.8 and 1.9 in to /opt/ruby1.8.6 and /opt/ruby1.9.0 respectively.

Before doing that I'll make sure I have all the necessary build dependencies for both packages
$> sudo apt-get build-dep ruby1.8 ruby1.9

Next I downloaded both packages into a working directory and decompress them
$>mkdir temp; cd temp
$>wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
$>tar -xvzf ruby-1.8.6-p111.tar.gz
$>wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz
$>tar -xvzf ruby-1.9.0-0.tar.gz

Next I build each of the packages.
$> cd ruby-1.8*
$> ./configure --prefix=/opt/ruby1.8 --program-suffix=1.8.6
$> sudo make && make install
$> cd ../ruby-1.9*
$> ./configure --prefix=/opt/ruby1.9 --program-suffix=1.9.0
$> sudo make && make install

Ruby 1.8 doesn't have built in support for gems like Ruby 1.9 so we'll have to install it.
$> wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
$> tar -xvzf rubygems-1.0.1.tgz
$> cd rubygems*
$> sudo /opt/ruby1.8.6/bin/ruby1.8.6 setup.rb
Notice that I specified the entire path to the ruby executable while installing RubyGems for 1.8.6

The next thing I do is create some symbolic links to make life a little bit easier.
$> sudo ln -s /opt/ruby1.8.6/bin/* /usr/local/bin
$> sudo ln -s /opt/ruby1.9.0/bin/* /usr/local/bin
Now test things a bit to make sure everything makes sense

$> which ruby
>> /usr/bin/ruby
$> gem env
>> ....
>> GEM PATH: /var/lib/gems/1.8
>> ....

$> which ruby1.8.6
>> /usr/local/bin/ruby1.8.6
$> gem1.8.6 env
>> ....
>> GEM PATH: /opt/ruby1.8.6/lib/ruby/gems/1.8
>> ....

$> which ruby1.9.0
>> /usr/local/bin/ruby1.9.0
$> gem1.9.0 env
>> ....
>> GEM PATH: /opt/ruby1.9.0/lib/ruby/gems/1.8
>> ....

A couple of things to watch out for:
  • Make sure you don't have any RubyGems environment variables set. They're not needed for any of this and most likley will mess something up.
  • Don't install any gems until after you create your symbolic links or the executable commands may clobber each other.
  • You have to specify the full path to an executable gem because they don't play nicely with program suffixes. So for example '/opt/ruby1.8.6/bin/rake' will do what you expect but just typing 'rake' may not.
One last little tidbit. I'm not sure if the Ubuntu RubyGems packages deal with fixing up the $PATH yet? Regardless the fix is easy; add this little bit of code to the bottom of your ~/.bashrc file
if [ -d /var/lib/gems/1.8/bin ]; then
PATH=/var/lib/gems/1.8/bin:"${PATH}"
fi
export PATH