Friday, September 18, 2020
Riffs from an overheated mind


concurrency java javaone Mac mysql puzzler rails ruby



Installing Rails, MySQL on Mac Leopard

April 19th, 2009 by hashbrown

Update: Some comments were mysteriously deleted, sorry if yours is not appearing, thanks for commenting though! One person responded that they needed to install the XCode tools first. I think they were building or upgrading ruby (which I didn’t do). There are certainly no issues with doing this step first, I just didn’t need to until I installed mysql.

I just recently finished tackling this oft attempted-failed-blogged-fixed(but not for you) ritual, getting a working ROR sandbox with mysql.
Many others have blogged about this, trust me I spent many days reading them, and the approaches and results are all over the map.
Sorry to say, this post is not the be-all end-all solution that other blogs claim. It’s just what I did, posted mainly for my own documentation.

First, my requirements. My web host, Site5, currently has installed Ruby 1.8.7 and Rails 2.2, plus MySQL 5.1.x. So I wanted my dev environment to be close to what my deployment environment will be.
I prefer to understand as much about my dev environment as I can, I want to know how things work, so that I can control them. So magic out-of-the-box solutions generally aren’t favored.
However, I’m generally the person that does it the hard way, and also runs into all those problems that people post about on the web, it never just works. And I’ve got a lot of grokking ahead of me as it is, so taking the easiest approach migh not be bad this time.

After researching this, I boiled down the options to 3 popular approaches:

  1. Use the default mac installation of ruby, upgrade the rails gem and install mysql
  2. Use MacPorts, which provides a pre-packaged install
  3. Build an entirely new environment from scratch, as detailed in the oft-cited Hivelogic article.

Option 1 seemed to be the easiest, but Leopard comes with Ruby 1.8.6 installed, I will use 1.8.7 in production, probably not a deal breaker. Also there is a potential that a future OS update could break something in my existing sandbox.

Option 2 gives me the magic all-in-one solution, but I always worry that I’m putting myself in their box. Plus the community seems pretty split on macports in general.

Option 3 gives me total control, and the best chance for everything going to hell.

In the end I decided on option 1, use the existing mac install and upgrade rails. I figured I start there, the other 2 options are still open to me if I find its needed.

“Finally, just get to it”. Surprisingly, everything worked very well, here’s how I did it.

In order to upgrade to 2.x rails gem, the gems package manager must be updated.

$ sudo gem install rubygems-update
$ sudo update_rubygems

Now update the rails gem.

$ sudo gem update
$ sudo gem update --system
$ sudo gem install rails

Now you can check your versions.

$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
$ rails -v
Rails 2.3.2

Ok, time install mysql. First thing is to make sure Xcode tools are installed.

If you have your Leopard installation DVD, load it now. If you don’t have an installation DVD, you can download the Xcode 3.0 tools at Apple’s Developer Web Site. (Note: Apple developer accounts are free.)

Open the Optional Installs folder, and then the Xcode Tools folder. Double click on the XcodeTools.mpkg installer and select a standard install. This will take a few minutes to run.

Download MySQL from their site. Make sure to get the 32-bit mac version.
This a native mac application and is installed like any mac app.

Once mysql has been installed, the mysql gem must be installed.

There seem to be 2 secrets to make it work. First you point the gem to the mysql client config folder, instead of the mysql home. Second, if on an intel machine, provide the env ARCHTYPE flag.

$sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-

ok, and that’s it. Now to make sure everything is wired correctly, I just created a super simple rails app, following this guide.

Posted in Mac, ruby/rails | 3 Comments »

I Didn’t Switch To Macs

April 18th, 2009 by hashbrown

The New Macbook Pro
But I did just buy my first one. After a lifetime spent mastering windows, I never had a desire for a mac, and the fact that all the cool kids were getting them, made one even less desirable.
But lately I’ve wanted to get into some iphone development, and a mac is required. Also, I’ve really needed to purchase a new laptop. I’ve been using my work laptop as a personal computer for years, but it always feels borrowed.
So, given that the new intel based macs do a great job of running windows as well, I swallowed my pride and bought a macbook pro.

Now, I’m not going to get all fanboy about this. They do have a great aesthetic and its a pretty tight user experience, but in reality, as much as Vista has been bashed, the UI experiences aren’t that far apart. This isn’t some mystical new experience in computing. But I’ll save final judgment until I’ve really used it for awhile.

The first thing I really like about it, is that the terminal is a bash shell, no crappy ms-dos prompt. Plus 100 for the mac. The other thing I really love is that it seems to run MUCH cooler than my Dell, which would be burning up my lap in about an hour (yes I use a laptop on my lap).
But for all the talk about how great the design and UI is, I find that I don’t like the fact that every application looks like iTunes. It just gives it this rigid cold feeling, where every single app has to comply with the “apple way”. No individuals in this world.
I’m having a hard time adjusting to the command key vs ctrl on windows. Also, Apple provides a Control key as well, but I don’t know what it does. So far I use it just to control-click the track pad to enable “right-click” type features. Also, the mac keyboard has the “fn” key where the ctrl key is on windows, so I’m constantly hitting that by mistake. And I don’t like the key spacing on cut/paste which is cmd-c/cmd-v. I’m just so used to doing with my pinky and index finger on windows, the cmd and c/v keys are too close together. So I just have to get used to that I guess.
But my biggest beef is the menu bar. I’m not used to looking to the top of the screen to see the application controls, I expect them to be at the top of the application’s window. So I find myself constantly clicking around and application, trying to find a menu I’m looking for, until I final remember, “oh yeah, it’s up there”.
I’m not bashing it though, just the initial perspective of new user, coming from an alternate system.
We’ll see how it goes.

BTW – This mac does not make me cool. I was cool long before it kids.


Posted in Mac | Comments Off