Installing RMagick on Ubuntu*

Posted by Ryan Baxter Thu, 20 Aug 2009 17:00:00 GMT

Because I always forget how…

sudo apt-get install libmagickwand-dev
sudo gem install rmagick

and you reference it in code like so:

# Don't forget the capital "RM"!
require 'RMagick'
include RMagick

*I’ve only done this using Ubuntu 9.04. Your mileage may vary.

Installing Ruby 1.8 and 1.9 on Ubuntu from Source

Posted by Ryan Baxter Sun, 14 Sep 2008 20:30:00 GMT

I’ve begun testing my fractal library with the latest source code from the Ruby 1.9 trunk. Since 1.9 is a development release and I still need 1.8 for my Rails applications, I’ve checked out both versions and configured them to run side-by-side on Ubuntu, Hardy Heron.

Before you begin, make sure you have the autoconf, build-essential, and subversion packages installed.

It may also be a good idea to include the Ruby1.8 and Ruby1.9 build dependencies from Ubuntu’s package repository. This could prevent some headaches later on.

$ sudo apt-get build-dep ruby1.8 ruby1.9

Create a directory for the Ruby source code.

$ mkdir /home/ryan/source
$ cd /home/ryan/source

Check out the code from the 1.8 branch. Since this branch includes patches, you can always update your source and recompile when new patches are released.

$ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 ruby1.8

Next, create a configuration, configure, and compile.

$ cd ruby1.8
$ autoconf
$ ./configure --prefix=/opt/ruby1.8 --program-suffix=1.8
$ sudo make
$ sudo make install

Finally, link your new binaries to the /usr/local/bin directory.

$ sudo ln -s /opt/ruby1.8/bin/* /usr/local/bin

Typing ruby1.8 -v in a new console should yield something similar to the following:

$ ruby1.8 -v
ruby 1.8.7 (2008-09-15 revision 19348) [i686-linux]

One of the best parts of Ruby is Rubygems! Download and install it.

$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
$ tar -xvzf rubygems-1.2.0.tgz
$ cd rubygems-1.2.0
$ sudo ruby1.8 setup.rb
$ sudo ln -s /opt/ruby1.8/bin/gem1.8 /usr/local/bin

The current source for Ruby 1.9 requires version 1.8 to compile, but if you’ve followed my directions up to this point you should be ready to download and compile the latest Ruby 1.9 source code.

Go back to your source directory and check out the latest code from the 1.9 trunk.

$ cd /home/ryan/source
$ svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby1.9
$ cd ruby1.9

This time use the –with-baseruby switch when configuring. Set this option to the new Ruby 1.8 binary and then compile.

$ autoconf
$ ./configure --with-baseruby=/usr/local/bin/ruby1.8 --prefix=/opt/ruby1.9 --program-suffix=1.9
$ sudo make
$ sudo make install

Finish by linking your new Ruby 1.9 binaries to /usr/local/bin.

$ sudo ln -s /opt/ruby1.9/bin/* /usr/local/bin

Typing ruby1.9 -v in your console should yield something similar to the following:

$ ruby1.9 -v
ruby 1.9.0 (2008-09-15 revision 19351) [i686-linux]

Ruby 1.9 includes Rubygems! We’re done!

Since the binaries we’ve created have been suffixed with either 1.8 or 1.9, you must remember to execute them with their proper name ie (gem1.8, gem1.9, ruby1.8, ri1.9).

I’ve written these instructions from memory so if you have any problems, please post them and I’ll try to help out as best I can. Please be warned, however, that not all code written for Ruby 1.8 will work in 1.9.

Samba Network Shares with Nautilus in Hardy Heron Part 2

Posted by Ryan Baxter Sun, 01 Jun 2008 23:07:00 GMT

Nearly a month ago I wrote about my problems connecting to the network shares of my Linksys NAS200 using Nautilus in Ubuntu, Hardy Heron. My fix was simple and it worked. Unfortunately, the solution’s WAF (Wife Acceptance Factor) was low. Apparently she didn’t think it was easy enough to execute smbmount from a Terminal window. Whatever :) I have since written a small shell script that is called from Session Startup.

Initially, the script failed to connect to my network shares because my wireless network connection hadn’t finished negotiating before the script was executed. I coded around this by creating a while loop that greps the output of a ping to my router. If successful, the mount_shares function is called. Otherwise. the thread will sleep for 10 seconds and try again.

#!/bin/bash

user="thorbardin/ryan%password"
root_dir="/home/ryan/Network Shares"

mount_shares() {
  public_dir="$root_dir"/"Public on Thorbardin"
  home_dir="$root_dir"/"Home on Thorbardin"

  [ -d "$public_dir" ] || mkdir -p "$public_dir"
  [ -d "$home_dir" ] || mkdir -p "$home_dir"

  smbmount "//192.168.1.105/public disk" "$public_dir" -o user="$user"
  smbmount "//192.168.1.105/ryan" "$home_dir" -o user="$user"
}

while [ 1 ]; do
  if ping -c2 192.168.1.1 2>&1 | grep ttl; then
    mount_shares

    exit 0   
  fi
  sleep 10
done

exit 0

I’m already thinking about rewriting this script so that it scans my network using smbtree and automatically mounts all available network shares. That’ll be Part 3!

Older posts: 1 2 3