Posts from June 2008

June 2008
Sun
Mon
Tue
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

Setting up Rails and MySQL on OS X Leopard

I recently purchased a MacBook to use as my primary development system. One of my first plans was to get up and running with Rails on this new machine. Given that Leopard (OS X 10.5) comes with Ruby version 1.8.6 and RubyGems 1.0.1, I thought I would be in good shape, but there were a couple of snags. Thanks to the power of Google and other people with similar problems, I was able to get it sorted out. Here’s what I did:

  1. Updated rubygems to 1.1.1 with sudo gem update --system
  2. Installed the 32-bit (x86, NOT x86_64) version of MySQL (community edition, of course) via the installer on the MySQL download page.
  3. Installed the native MySQL driver for Ruby (this was tricky, see below)
  4. Finished by installing Rails and its friends via gem install rails

Getting the speedier native MySQL driver for Ruby installed was tricky for two reasons. It seems that by default the installer attempts to compile for 4 architectures, so you have to set an environment variable and pass along a parameter to point to the installed copy of MySQL when calling gem:

sudo env ARCHFLAGS=”-arch i386” \
   gem install mysql -- \
   --with-mysql-config=/usr/local/mysql/bin/mysql_config

If you’ve never seen it before, the ‘–’ after ‘gem install mysql’ means that gem should pass along the next arguments to the programs it uses to build the driver.

The reason for installing the 32-bit version of MySQL (on your fancy 64-bit OS and machine!) is that the version of Ruby that ships with Leopard is apparently 32-bit only. Yikes.

I’ve noticed several little annoying details like this in getting other things to work “like I like” on OS X. I’ll probably end up posting more about them in the next couple of posts.

I know that “how to” posts of the form “I wanted to do X, but Y happened. Finally I fixed it by Z,” are pretty boring. Still, I hope they are useful for preserving the knowledge of how to work around these problems, both for myself and for others.

Getting the Boarduino working with OS X Leopard

I’ve been into hardware hacking on and off for much of my life, but I’ve never really had the time and confidence to design and build my own hardware. In recent years, projects like the open source Arduino have been slowly convincing me that I just might be able to do this stuff.

When a recent Make blog article showed nearly step-by-step instructions for building a breadboard-friendly Arduino clone called the Boarduino, I felt compelled to order one and try to get it working with my new MacBook.

I ordered the DC Boarduino kit from LadyAda’s website, along with the USB TTL-232 cable that would connect to my laptop’s USB port. I also ordered the 9V power supply on the site to power the Boarduino.

I found building the Boarduino to be pretty easy (=ahem= with only one screwup on my part) thanks to LadyAda’s detailed instructions. It was the first soldering project I had done in awhile, so I am happy that it went so well.

I next looked to the Arduino OS X guide for the software download and installation instructions. I ended up grabbing version 11 of the Arduino software. After unpacking the .zip file from the site, I installed the FTDI driver and rebooted, then plugged in the Boarduino’s power and connected it to the laptop via USB.

Next, I double-clicked the Arduino application to start it, and nothing happened. After messing around with it on the command line for awhile, I determined that it didn’t like the version of Java I’m using (I have the 64-bit version of Java 6 as my default).

So, to run the Arduino software, I had to temporarily set my preferred Java version to 5.0 via the Java Preferences panel in /Applications/Utilities/Java/. Once I had changed my Java version, the Arduino app started right up with a double-click. Once I was done with the app, I could set my Java preferences back to Java 6.

In the Arduino app, I set it up to communicate with the Boarduino by selecting “Arduino NG or older w/ ATmega168” under the Tools | Board menu. I then opened up the Blink test program under File | Sketchbook | Examples | Digital | Blink. To load the program onto the Boarduino, I pressed its reset button, then quickly clicked the “Upload to I/O Board” button on the interface.

The red LED on the Boarduino blinked rapidly as data was received, then it started blinking slowly as it ran the Blink program! Hooray!

I’m excited that it’s so easy to get something as powerful and versatile as the Boarduino up and running in just a couple of hours. I’m going to try and think of a couple of projects for it. Whatever I do, I’ll be sure to post about it here.

A couple of Leopard configuration tricks

I find Google to be a more and more valuable resource as time goes on, especially when seeking knowledge about how to make this new MacBook act like I want it to.

One thing I noticed early on was that pressing Tab to move around various interfaces, from Finder dialogs to web pages, would only tab to text entry fields. Coming from a primarily Windows background, I am used to tabbing my way to checkboxes, dropdowns, and buttons in my interfaces, so this crippled Tab navigation quickly became annoying.

Thanks to this blog post, I found the option to make Tab move through “All Controls” in System Preferences | Keyboard & Mouse | Keyboard Shortcuts

Another big issue I came up against is the weird Java support that comes with OS X. Because Apple releases their own versions of Java, we OS X users are kind of at their mercy with respect to what we can use and how we can configure it. You can install Java 6 from Apple’s download page, but Java 1.5 will still run by default.

Apple provides a “Java Preferences” configuration utility in /Applications/Utilities/Java/ which lets you change the default version of Java that will be used in browsers and when double-clicking to launch Java apps. However, this utility doesn’t change which version of Java will be found by command-line apps in the terminal, such as Apache Ant.

Another blog post to the rescue! It turns out that you can change your default version of Java for command line apps freely by changing the CurrentJDK and Current symlinks in /System/Library/Frameworks/JavaVM.framework/Versions/. For example:

    cd /System/Library/Frameworks/JavaVM.framework/Versions
    sudo ln -fhsv 1.6 CurrentJDK
    sudo ln -fhsv 1.6 Current

Hopefully this post will be able to help others (or at least my future self).