After doing a clean install of Leopard (on a blank partition) and importing user settings / home directory, this is what I needed to do to install the Ruby on Rails development environment on Leopard OS X 10.5.
TextMate transferred OK as an application during the import phase after the install of Leopard. The only thing needed was a re-setting-up of the command line launcher for Textmate. A symbolic link to TextMate’s mate program in Applications placed within the /usr/bin directory does the trick:
sudo ln -s /Applications/TextMate.app/Contents/Resources/mate /usr/bin/mate
- Download OS X 10.4 pre-compiled mysql binary from MySQL.com (use FTP link if you can, for some reason Firefox recognized .dmg as text mime type for the HTTP link).
- Double click the .dmg file to mount the disk image.
- Run the mysql-5.0.45-osx10.4-i686.pkg installer.
- Run the MySQLStartupItem.pkg to have MySQL start upon system boot.
- Add the location of the mysql executable to your path. For me this involved adding a line to my .profile file in my home directory
- Then start the mysql daemon
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
- At this point there should be a socket file created in your /tmp directory for connecting to mysql. Check that the following file exists: /tmp/mysql.sock
- Login to mysql and change the root password:
mysql -h localhost -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('root-pwd') WHERE user='root';
mysql> FLUSH PRIVILEGES;
- Create any other mysql accounts you need:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'prod'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
(do not include the backslash ” in this command, which was used to denote a wrapped line)
- At this point you might want to clear out your mysql command cache (which contains what password you just set for root) located in your home directory.
echo -n > ~/.mysql_history
- Now load your data back into MySQL. For me this consisted of exporting the database from the production site
mysqldump -u <username> -p -q --single-transaction <db_name> > <backup_filename>
then create the database within mysql before importing to that database
mysql>create database my_kickin_database
From the terminal:
mysql -u <username> -p my_kicking_database < <backup_filename>
Despite all the badpress RMagick gets about using scads of RAM and that ImageScience is a better solution, RMagick is still quite useful. The RAM stuff is also not an issue if you can figure out how to do your image manipulation calls via command line. Plus it’s got a lot more features than FreeImage/ImageScience and in my experience, more stable as well.
Solomon White’s got a great shell script for installing ImageMagick and RMagick from source without MacPorts and that’s the route that I’ve chosen to go. Check the instructions at his page. Thanks Solomon.
Be sure to install Mac OS X XcodeTools from the Leopard install DVD (Optional Installs/Xcode Tools/XcodeTools.mpkg) before attempting this source install of ImageMagick/RMagick; The compilers necessary to build these packages are not installed on OS X by default. In particular what you need are Developer Tools Essentials and UNIX Development Support. All other stuff in the Xcode Tools package are not essential for this install. Install those two packages. Should take about five minutes or so.
You may want to run each of the steps listed in Solomon’s script one at a time in case one of the them fails. You wouldn’t want to finish building ImageMagick from source (not exactly quick) when you find out that your download of the jpeg source libraries failed and ImageMagick got built without JPEG support. (This is a current issue with the jpeg source download source that Solomon’s script is using for the download, so caveat emptor).
UPDATE: The RMagick gem install may fail with an error of “too many examples failed” if the compilation and install of the jpeg package did not install static nor shared libraries (default behaviour). What this means is that the JPEG package is installed binary executable files, but not libraries that other programs such as ImageMagick can use to manipulate photos and image files. This is easy to correct. To make sure that the JPEG package installs the actual JPEG libraries do the following within the jpeg-6b directory (which was created when you untar’d the jpeg6b.tar.gz source file):
cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . ./configure --enable-shared --enable-static make sudo make install
Thanks to Matt King for posting instructions on fixing the JPEG library ImageMagick / RMagick errors.
That should be all that’s required to install the actual JPEG libraries. Now return to the ImageMagick directory (also created when you untar’d the ImageMagick source files) and try configuring and building again (NOTE: the “configure” line is just one line, no carriage returns in between all those –with –without command line arguments):
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts make sudo make install
This is the god of command line debugging for Rails. Grab it and gem install that baby. Once you get used to it, you’ll love it.
Once you’ve got these guys installed you should check whether you need any other gems specific to your Rails project. The gems you can skip since Mac OS X Leopard’s Ruby install includes them already: Capistrano 2.0 (and requirements), RedCloth 3.04, mongrel 1.01, hpricot .6, fastthread 1.0 and perhaps others that I’m forgetting about.
At this point, wander over to your Rails project directory and fire it up (using ruby-debug of course): rdebug -n script/server and check that everything is peachy. If things blow up, don’t panic. Things to check:
- If you were previously using MacPorts for your MySQL install, you’ll likely have a different sockets file location now. By default MacPorts slapped the socket file somewhere like: /opt/local/var/run/mysql5/mysqld.sock Although now you’re playing with a socket file in /tmp/mysql.sock. Head over to your config/database.yml file in your Rails project and make sure your development environment is pointing at the right socket file and that the socket file is actually there.
- Read over the webrick log that’s upchucked an error. Good chance that at the top of that error you’ll see a call to some missing gem that you’ve forgotten to load up. Head on over to RubyForge and rectify your situation.