More articles about Development

More articles about Ruby on Rails

Setting up Rails on Leopard (Mac OS X 10.5)

By Christopher Haupt

Published July 19, 2008  |   comments

This guide walks you through setup instructions for preparing a Mac OS X 10.5 (aka Leopard) development machine to be used for general Ruby on Rails coding. This baseline setup is what we use for our LearningRails online course.

You will end up with a development machine with the following baseline components:

  1. Ruby and all basic Ruby utilities
  2. Ruby Gems package manager
  3. Subversion client
  4. Git client
  5. Native development tools (Xcode, C compiler)
  6. MacPorts native code package manager
  7. MySQL database client utilities and server
  8. Gems for Ruby on Rails, Capistrano, Mongrel, Mongrel Cluster, and MySQL
  9. Programmer’s editor or IDE

Note: In the command sequences we illustrate here, command line prompts are shown as a dollar sign ($).

Prerequisites

This guide assumes you have a Macintosh computer running the current Leopard operating system with up-to-date System Update patches applied. It also assumes you have not set up alternate Ruby on Rails tools prior to running through this guide. If you have, then small adjustments may be required as you walk through the following instructions.

You will need to have access to an Internet connection to complete various download steps.

You will need to have administrator access to your computer to complete this guide. We will be using the sudo command to run various command line programs and some of the Mac OS X native installers will also ask you for your password.

It is helpful if you have access to your operating system installation discs.

The Recipe

Follow this recipe in sequence. If you have previously installed a particular component, you can usually skip the associated step.

Ruby and Ruby Utilities (irb, ri, rdoc)

Leopard comes pre-installed with Ruby 1.8.6 and its associated utilities. You can use these programs as is. To check them out, open a Terminal window and type:

	$ which ruby
	/usr/bin/ruby
	$ ruby -v
	ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

You should seem similar responses. The important one is the first one which reports back the path of the Ruby interpreter program. If you are using the built-in Ruby, it will be located in /usr/bin/.

Ruby Gems Package Manager

Leopard comes with a pre-installed version of gem. Be sure you have the latest version:

	$ gem -v
	1.0.1

You need 1.0.1 or newer. If you have an older version, you can update with the command line: sudo gem update --system.

Native Development Tools (Xcode 3.0)

You will need a native compiler to build many of the gems’ native libraries you are going to use. You will also occasionally build other native tools via the MacPorts tool described below. Apple provides a free native compiler tool set called Xcode. 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:

MacPorts

MacPorts is a native code package manager for Macintosh software. This guide uses MacPorts to setup an installation of MySQL and the Git distributed version control system. There are many other tools available in the MacPorts library, so it is well worth checking out.

Download the Leopard Universal version (1.6.0 at the time of this writing) and double click the MacPorts DMG file to open it up. Double click on “MacPorts-1.6.0.pkg” to start the installer and select the default options.

After MacPorts completes installation, you need to adjust your command line PATH environment variable so you can run the port command.

Fire up the Terminal program and enter the command:

	$ open .bash_profile

Note that there is a period in front of “bash_profile”. The bash shell configuration file should open in the TextEdit program. If you don’t have a .bash_profile, you can create a new one in your text editor and save it in your home directory.

(By the way, we recommend iTerm as a nice open source replacement for the Apple Terminal program.)

Inside of .bash_profile, find the line that starts with export PATH=, if present. You are going to insert the new directories used by MacPorts into your path:

	export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

If you don’t have a line that exports your PATH, use the text exactly as above. If you do already have such a line, add the /opt/local/bin:/opt/local/sbin: (note colons) after the first quote, but before any other paths. Here is an example:

	export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:$PATH"

Save the file and close TextEdit. Open a new terminal window and have MacPorts update itself with the command:

	$ sudo port selfupdate

Installing Git via MacPorts

Git is all the rage in the Rails world now and has pretty much replaced Subversion as the version control system of choice. That said, both are in common use. Currently Leopard doesn’t install git by default, so we’ll use MacPorts to quickly install git:

 	$ sudo port install git-core +doc +svn

This command installs the core git tools, the man page documentation, and integration with Subversion. This last is useful if you plan on migrating from or need to work with a legacy Subversion repository. The installation will take a while; it has a lot to load.

Besides your own project version control, you’ll typically use git when loading Rails 2.1 and various 3rd party plugins.

Installing MySQL via MacPorts

By leveraging MacPorts to install MySQL, maintenance of the software is slightly easier, especially when you want to upgrade over time. We are using MySQL on our development machine as we prefer to have identical software across our environments. Rails 2.0.2, 2.1 and newer uses SQLite by default, which is fine for development and experimentation, but not appropriate for production code.

To get started, type into your terminal window:

	$ sudo port install mysql5 +server

This command downloads and installs the baseline MySQL client programs and server software. Next, you want to configure MySQL’s server so it launches when your computer boots up:

	$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

launchctl is an Apple tool that administers the system daemon that controls the boot process and background programs. Here you are loading the instructions for how to manage MySQL.

A fresh MySQL installation requires its database storage area to be initialized, so you do that next:

	$ sudo mysql_install_db5 --user=mysql

When you configure the storage area with this command, you’re making sure it is owned by the user “mysql”.

MySQL creates a special system file used for program to program communication, called the “socket” file. By default, the MacPorts installation of MySQL server creates this in the directory “/opt/local/var/run/mysql5/mysqld.sock”. Ruby on Rails applications can deal with this just fine if you change the settings in your database.yml file to include a socket entry that points to the correct place. However, we are going to tweak things so all applications can find the file in a fairly standard place: /tmp/mysql.sock with little or no modification.

First, you need to move the default configuration file, my.cnf, to the correct place:

	$ sudo mv /opt/local/etc/my.cnf /opt/local/etc/mysql5/my.cnf

If the installation program didn’t put a file into /opt/local/etc/, try this instead:

	$ sudo mv /opt/local/share/mysql5/mysql/my-medium.cnf /opt/local/etc/mysql5/my.cnf

Now, you need to edit the configuration file to change where the socket file is stored:

	$ sudo pico /opt/local/etc/mysql5/my.cnf

If you aren’t familiar with the pico command line editor, we explain the few commands you will need here.

Inside of pico, use your arrow keys to move down to the line where you first see “[client]” and make the following changes (this is just a small part of the whole file):

	...
	# In this file, you can use all long options that a program supports.
	# If you want to know which options a program supports, run the program
	# with the "--help" option.
	
	[mysqld_safe]
	socket          = /tmp/mysql.sock

	# The following options will be passed to all MySQL clients
	[client]
	#password       = your_password
	port            = 3306
	socket          = /tmp/mysql.sock

	# Here follows entries for some specific programs

	# The MySQL server
	[mysqld]
	port            = 3306
	socket          = /tmp/mysql.sock
	...

You are adding the “[mysqld_safe]” section (2 lines) just above “[client]” and then changing the two instances of the "socket = " lines in the “[client]” and “[mysqld]” sections to be /tmp/mysql.sock. Once done, press Control-X, answer Y when asked to save, and press return to accept the default file name (“my.cnf”).

Now you start the server up manually:

	$ cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &	 

You can confirm that MySQL is running by trying to fire it up:

	$ mysql5 -p -u root
	Welcome to the MySQL monitor.  Commands end with ; or \g.
	Your MySQL connection id is 1
	Server version: 5.0.45 Source distribution

	Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

	mysql> exit

When you reboot your computer, MySQL should start automatically in the future.

Gems

Leopard conveniently pre-installs the base collection of gems you will be using, but you need to make sure they are up to date:

	$ sudo gem update

All installed gems (including Ruby on Rails and its dependencies, Rake, Capistrano, Mongrel, and Mongrel_Cluster) will get updated.

The MySQL adapter gem needs to be installed, and it is a little finicky due to our use of MacPorts.

If you are running Leopard on an Intel processor, use this command (on one line):

	$ ARCHFLAGS="-arch i386" sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5

and if you are on a PowerPC processor, use this command:

	ARCHFLAGS="-arch ppc" sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5

Once the command completes, you should be all set with the baseline gems you will need for the LearningRails courses.

Code Editing Tools

While you can get by with using a plain text editor like TextEdit, or even Apple’s Xcode IDE, you will be more productive if you use a programming editor that is highly tuned to Ruby on Rails development.

We use the commercial TextMate programmer’s editor for much of our day-to-day work. TextMate is highly extensible through a collection of community supplied “bundles”. Many add-ons accelerate development by enhancing the editor (for example, adding language specific short cuts to reduce your typing) or by tying in to other utilities, such as Subversion or Rake, to allow you to quickly get tasks done without leaving the editor’s environment.

There are a variety of good open source or free programmer editors available too. On the open source side, Leopard comes pre-installed with both vim and emacs. jEdit is a very extensible open source editor written in Java. TextWrangler is a free programmer’s editor from BareBones.

Whatever editor you choose, be certain that it provides easy navigation among a large number of open files. Working with Rails applications generally involves dealing with a lot of small files, and that process needs to be efficient.

If you prefer an all-in-one tool, ook at one of the integrated development environments for Ruby. We use Netbeans when we aren’t using TextMate, but the numerous other options listed at BuildingWebApps.com are worth a look.


Add your comment on this article






Reader comments on this article

From: Christopher Haupt       Date: 11/14/08 12:00 AM

Subject: RE: SUDO doesn't work

Freddy,

Try just the sudo command alone:

sudo -s

on the command line. It should ask for your password and leave you at a # prompt by default (your prompt may vary depending on OS version).

To check ports (and your paths) try which port and port installed. Do you get responses?

Did the port selfupdate run ok?

-c

From: Freddy Rodriguez       Date: 11/13/08 09:21 PM

Subject: Sudo doesn't work.

I’ve been trying to Google answers for this almost all day.

I can’t even install git-core. I try typing “sudo port install git-core +doc +svn”, it then prompts me for my password, I enter my password, and then it takes me back to the command line without installing anything.

I tried installing without typing “sudo”, but then it gives me an Error: Unable to execute port: can’t create directory “/opt/local/var/macports/build”: permission denied.

Any ideas? I’m tearing my hair out.

From: Jordan       Date: 11/06/08 11:23 PM

Subject: Thanks Brandon

I had the same problem, but your solution worked like a charm:

From: Brandon Date: 08/22/08 02:14 PM

Subject: RE:Error installing git-core..

I had a problem installing the git-core on Leopard as well but my problem was concerning AWK. Even though AWK is installed on my system macports didn’t find it. So my solution was to “sudo port install gawk” and then the git-core installed just fine.

From: Felix       Date: 10/27/08 10:10 AM

Subject: Problems starting mysqld_safe

I had the problem starting mysqld_safe. The reason was that I simply used the command as given:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe & .

But without the &, the mysqld started correctly. So this is the correct command:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe

From: Felix       Date: 10/27/08 10:10 AM

Subject: Problems starting mysqld_safe

I had the problem starting mysqld_safe. The reason was that I simply used the command as given:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe & .

But without the &, the mysqld started correctly. So this is the correct command:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe

From: Felix       Date: 10/27/08 10:10 AM

Subject: Problems starting mysqld_safe

I had the problem starting mysqld_safe. The reason was that I simply used the command as given:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe & .

But without the &, the mysqld started correctly. So this is the correct command:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe

From: Christopher Haupt       Date: 10/14/08 04:04 AM

Subject: RE: Same Problem as Will Law

It is possible that you have a typo in for the name of the socket file in the configuration file. The instructions call it “mysql.sock” (note, no “d” at the end, and not “my.sock”). Of course, if you have other customizations that is moot.

Check that first, see if anything is showing up in /tmp that looks remotely like a mysql file. If so, what is the name?

So, double check the config file and work outward from there. If you want us to take an extra peek, you could email the my.cnf file to us on the contact form

-Christopher

From: Rich Webster       Date: 10/14/08 01:01 AM

Subject: Same problem as Will Law...

I had problems identical, it appears, to Will Law, below. I’d rather not reinstall my system. Here’s where I am:

Macintosh-5:~ richwebster$ sudo pico /opt/local/etc/mysql5/my.cnf
Macintosh-5:~ richwebster$ cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &
1 51204
Macintosh-5:local richwebster$ A mysqld process already exists
mysql5 -p -u root
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysqld.sock’ (2)
1+ Exit 1 sudo /opt/local/lib/mysql5/bin/mysqld_safe
Macintosh-5:local richwebster$ which mysql5
/opt/local/bin/mysql5
Macintosh-5:local richwebster$
Macintosh-5:local richwebster$ sudo find /opt -name “my*.sock” -print
Macintosh-5:local richwebster$ sudo find / -name “my*.sock” -print
Macintosh-5:local richwebster$

any clues?

From: Rich Webster       Date: 10/14/08 01:01 AM

Subject: Same problem as Will Law...

I had problems identical, it appears, to Will Law, below. I’d rather not reinstall my system. Here’s where I am:

Macintosh-5:~ richwebster$ sudo pico /opt/local/etc/mysql5/my.cnf
Macintosh-5:~ richwebster$ cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &
1 51204
Macintosh-5:local richwebster$ A mysqld process already exists
mysql5 -p -u root
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysqld.sock’ (2)
1+ Exit 1 sudo /opt/local/lib/mysql5/bin/mysqld_safe
Macintosh-5:local richwebster$ which mysql5
/opt/local/bin/mysql5
Macintosh-5:local richwebster$
Macintosh-5:local richwebster$ sudo find /opt -name “my*.sock” -print
Macintosh-5:local richwebster$ sudo find / -name “my*.sock” -print
Macintosh-5:local richwebster$

any clues?

From: chris       Date: 10/11/08 04:16 PM

Subject: my.cnf file

Hi,

As a follow up question, I’ve tried to move the my.cnf file, but got this error:

mv: rename /opt/local/etc/my.cnf to /opt/local/etc/mysql5/my.cnf: No such file or directory

What does this error mean? I tried searching for it, but could not find a solution.

From: chris       Date: 10/11/08 03:03 AM

Subject: MySQL launch when computer boots up

Hi,

First off, thank you very much for these tutorials, they have been great. With that, I have a question about the following command:

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

I’m a complete beginner, but why would someone want to have the server start right when your machine boots up? Is it necessary?

From: James Grubb        Date: 08/25/08 02:14 PM

Subject: Firing up Mysql

Following the instructions to ‘fire up mysql’ and typing $ mysql5 -p -u root in the terminal, teminal appears to ask for a password. Just hit return as no password is required

From: Stephen       Date: 08/25/08 05:05 AM

Subject: dependencies failed to build

After running for a long time, I saw the following output and I’m wondering if it matters:

checking if you want to build C++ binding and demo… yes
checking if you want to build with Ada95… no
checking if you want to build programs such as tic… yes
checking if you wish to install curses.h… yes
checking for mawk… (cached) no
checking for gawk… (cached) no
checking for nawk… (cached) no
checking for awk… (cached) no
configure: error: No awk program found

Error: The following dependencies failed to build: p5-svn-simple subversion-perlbindings apr-util sqlite3 gawk gettext ncurses ncursesw gmake readline cyrus-sasl2 neon serf subversion p5-term-readkey rsync popt
Error: Status 1 encountered during processing.
MBPro:~ stephen$

From: Brandon       Date: 08/22/08 02:14 PM

Subject: RE:Error installing git-core..

I had a problem installing the git-core on Leopard as well but my problem was concerning AWK. Even though AWK is installed on my system macports didn’t find it. So my solution was to “sudo port install gawk” and then the git-core installed just fine.

From: Steve       Date: 08/17/08 12:00 AM

Subject: Error creating MySQL Adapter Gem

Can some one tell me why gcc is trying to compile the adapter using ‘-arch ppc’ when I have an intel machine and pass it ‘-arch i386’. You can see that it has both flags (‘-arch ppc -arch i386’) in the actuall gcc command for some reason. Being new to the mac I can’t find where gcc was installed (via xcode I believe) or where the configuration files are kept. Any tips/clues how to fix this would be greatly appreciated…

Thanks,
Steve

$ ARCHFLAGS=“-arch i386” sudo gem install mysql — —with-mysql-config=/opt/local/bin/mysql_config5
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql — —with-mysql-config=/opt/local/bin/mysql_config5
checking for mysql_ssl_set()… no
checking for mysql.h… yes
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_MYSQL_H -I/opt/local/include/mysql5/mysql -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -c mysql.c
cc -arch ppc -arch i386 -pipe -bundle -o mysql.bundle mysql.o -L"." -L"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib" -L. -arch ppc -arch i386 -lruby -L/opt/local/lib -L/opt/local/lib/mysql5/mysql -lmysqlclient -L/opt/local/lib -lz -lm -L/opt/local/lib -lssl -lcrypto -lpthread -ldl -lm
ld warning: in /opt/local/lib/mysql5/mysql/libmysqlclient.dylib, file is not of required architecture
ld warning: in /opt/local/lib/libz.dylib, file is not of required architecture
ld warning: in /opt/local/lib/libssl.dylib, file is not of required architecture
ld warning: in /opt/local/lib/libcrypto.dylib, file is not of required architecture
Undefined symbols for architecture ppc:
“_mysql_store_result”, referenced from:
_store_result in mysql.o
_query in mysql.o

From: Harry Llewelyn       Date: 08/12/08 02:14 PM

Subject: Re: Subject: RE: Error installing git-core

Thanks for the response :)
Yeah, mysql has a problem starting with that .sock file. The command has moved it, but there’s nothing inside the folder..

sudo port install readline – seems to be working alright though..

Something has also happened to my MySQL install on MAMP, as has since been refusing to start up.. I’m presuming its related as it was fine before!

Thanks for your reply!

From: Christopher Haupt       Date: 08/11/08 03:03 AM

Subject: RE: Error installing git-core

Harry: Do you run in to problems installing MySQL in the next step? Do you get any other diagnostics? Any problems when installing XCode? Try something simpler, like

sudo port install readline

And see if it runs through. If you can build a few things, it might be worth trying git-core again without the +doc and +svn to see if we can track down where the failure occurs.

From: Harry Llewelyn       Date: 08/09/08 10:10 AM

Subject: Error installing git-core..

When I do the
$ sudo port install git-core +doc +svn
command I get the following message after most of it seems to be installed.

Error: The following dependencies failed to build: p5-svn-simple subversion-perlbindings apr-util sqlite3 gawk gettext ncurses ncursesw gmake readline cyrus-sasl2 neon serf subversion p5-term-readkey rsync popt
Error: Status 1 encountered during processing.

Any ideas? Is this important?

From: Christopher Haupt       Date: 08/05/08 06:06 AM

Subject: RE: Error 2002

Sorry that you had to go through such extreme measures. Hopefully if the clean install is working for you. If folks run in to issues with older installs, add comments here. If common problems emerge over time, we’ll try to get those answered.

This article is updated from time to time when new bits (like git) are needed for the more “common” Rails development paths.

From: Will Law       Date: 08/03/08 12:00 AM

Subject: Error 2002 - The elusive sock file

Christopher, thanks again for the help. Unfortunately despite my best efforts I haven’t been able to fix it. I understand the mysql.sock file is created when the Mysql is running and it disappears when you stop running Mysql. So, my problem (I think) is in the fact mysql would not start up and run properly, despite the fact that mysql.sock could well be in the correct place, it’s just never created because something went wrong before that point.

So, I’ve gotten a little extreme and re-installed Leopard. Otherwise I know I’ll be here for weeks trying to just run a MySQL database! Nothing like a fresh install anyway to clear the air…

Thanks for the help all the same. If it doesn’t work this time around I’ll be sure to smash my computer to little bits, so it won’t matter either way. :)

From: Christopher Haupt       Date: 08/01/08 05:17 PM

Subject: RE: Error 2002

You should be able to track down the existing socket file in your /opt hierarchy. It may be in /opt/local/var/run/mysql5/, for instance. You can use the command:

sudo find /opt -name “my*.sock” -print

to find it if not (substitute other directories for /opt if need be). You might want to also look for the configuration file (my.cnf or other .cnf file) with the same technique.

Once you locate the sock file, you could make a new link to it in /tmp, though that has the potential of being cleaned out from time to time. The alternative is to follow the article walkthough and set up your my.cnf with the socket being created in the /tmp area directly.

From: Will Law       Date: 07/31/08 10:10 AM

Subject: ERROR 2002

Thanks Christopher for getting back to me so quickly! When I originally set up MySQL I followed the tutorial at Hive Logic (http://hivelogic.com/articles/2007/11/installing-mysql-on-mac-os-x). I didn’t use MacPorts.

Currently, (using ‘which mysql5’ to check) Mysql resides in “/opt/local/bin/”. However, these are just shortcuts to files residing in “/opt/local/lib/mysql5/bin/”…

The mysql.sock listed at ‘/tmp/’ does exist, but it is a shortcut to a file that doesn’t exist. Where is the original mysql.sock?

From: christopher Haupt       Date: 07/31/08 03:03 AM

Subject: RE: ERROR 2002

You should be just fine with a previous MySQL install, presuming it isn’t too old. You may have to tweak your MySQL configuration to get things working. How to do that depends a little on how it was originally installed. Did you use MacPorts? Typically, if your install is located in the /opt/local directory tree, than probably yes. (type “which mysql5” to check)

From there, you could actually pick up with the above instructions where we talk about tweaking the configuration file to locate the mysql.sock file.

If your install is located elsewhere, instructions are a little different. Let us know and we can give you some pointers.

From: WIll Law       Date: 07/31/08 12:00 AM

Subject: ERROR 2002 - Cannot connect to local MYSQL server through socket

Great article, however I’ve run in to some problems. Obviously, I’m running Leopard. I have had a previous installation of MYSQL before I tried following the instructions here.

Typing in…
$ mysql5

Gives back this…
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

I’ve tried searching the web, but most of the forum banter out there is unhelpful. If it’s because I need a clean install of mySQL, how do I remove my old versions?

From: Justus       Date: 07/28/08 02:14 PM

Subject: acces denied

Thanks. BTW: Just calling ‘mysql5’ without the ‘-p -u root’ will also confirm that the db is up and running.

From: Chris       Date: 07/25/08 12:12 PM

Subject: Justus, it sounds like your MySQL database is rejecting the root login you’re using. You need to make sure that the password in your database.yml file matches the one that has been set in MySQL for the corresponding user name (root in this case).

How do you do this, step by step?

“Justus, it sounds like your MySQL database is rejecting the root login you’re using. You need to make sure that the password in your database.yml file matches the one that has been set in MySQL for the corresponding user name (root in this case).”

From: Christopher Haupt       Date: 07/20/08 12:00 AM

Subject: Article updates...

I updated this article to fix some of the typos and add installation of git via MacPorts. You’ll need git to install many current Rails 2.1 plugins.

From: David Williamson       Date: 07/12/08 04:16 PM

Subject: typo, please add an end quote to the following line of this page:

typo, please add an end quote to the following line of this page:

export PATH=”/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:$PATH

From: David Williamson       Date: 07/12/08 04:16 PM

Subject: typo, please add an end quote to the following line of this page:

typo, please add an end quote to the following line of this page:

export PATH=”/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:$PATH

From: Phil Maxwell       Date: 07/06/08 05:17 PM

Subject: RE: Can't connect to MySQL server

Paul, make sure you don’t have any typos in ”/opt/local/etc/mysql5/my.cnf” It sounds like your socket file is missing.

From: Paul Denlinger       Date: 07/06/08 09:09 AM

Subject: Can't connect to MySQL server

I have fixed my problem in the previous posting so please disregard it.

My problem now is that when I try to fire up the MySQL server, I get the following error message. I have tried and retried several times to no avail, even though I have gone into pico and changed the settings in three places, as you specified.

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ’/tmp/mysql.sock’ (2)

From: Paul Denlinger        Date: 07/04/08 02:14 PM

Subject: Fine up until end

Thank you for your very detailed directions.

Everything worked fine for me until I got near the end and entered the:

sudo mv /opt/local/share/mysql5/mysql/my-medium.cnf /opt/local/etc/mysql5/my.cnf

command. When I pressed “Enter”, the shell just returned the original command back to me. I ignored this, and then entered the:

sudo pico /opt/local/etc/mysql5/my.cnf

Again the shell returned the original command to me. This time, I knew something was wrong because I needed to enter the pico environment.

Can you tell me what I need to do to complete the installation?

Thank you.

From: Lee Jones       Date: 07/03/08 05:05 AM

Subject: Lengthy times to execute terminal commands

Hey Jose,

I’m new to rails and installing all this stuff, but it took my iBook G4 over an hour to install mysql… not sure if that is normal. I did not actually see how long it took because I left it overnight after waiting about an hour. It was done and works great the next day. Now I am waiting on the gems to update…

Thanks Michael and Christopher for such a great resource. I tried to get rails installed before but did not have such a detailed guide to help me. This time was a breeze.

From: Jose Ignacio       Date: 06/26/08 08:08 AM

Subject: awesome Christopher

This is my first week with a mac. So this was really helpful…. A lot easier to install here than PC. Thank for the detailed step by step recipe Christopher, you guys are doing an awesome job. The podcast are better than all the books I was trying to read (even though I am not a php programmer). Love the high level view!!

My quick question is about how long it takes for each step to happen. I am still waiting on the mac to install mysql, it seems to be stuck at: Attempting to fetch….

Also, could you recommend any tutorial for terminal basic commands/unix I guess.

Thank you!

From: Sven       Date: 06/19/08 11:11 AM

Subject: Mac OS 10.5.3 break gem update ?

I have tried to follow your instructions on my MacBook and failed on the “sudo gem update” command. Afterwards Rails isn’t responding to “rails -v” anymore and trying to create a new project returns an error. Since I did succeed on another computer I tracked down the origin of this problem to the latest update of Leopard. Even after a clean install the gem update fails on several gems and break Rails on 10.5.3. Any solution ?

From: Michael Slater       Date: 06/19/08 09:09 AM

Subject: access denied

Justus, it sounds like your MySQL database is rejecting the root login you’re using. You need to make sure that the password in your database.yml file matches the one that has been set in MySQL for the corresponding user name (root in this case).

From: Justus       Date: 06/19/08 04:04 AM

Subject: Error when testing MySQL

I’m getting the following error message:

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

Thanks!

From: Christopher Haupt       Date: 06/05/08 09:21 PM

Subject: RE: I have no .bash_profile

Magnus: Absolutely. If you don’t already have a .bash_profile file, go ahead and create one and drop the PATH line in.

From: Magnus       Date: 05/30/08 01:13 PM

Subject: I have no .bash_profile

Im very new in the terminal window.
open .bash_profile says “file not found”. I gather i dont have one, as i have been searching around for it.

Can i just create one, with only this PATH line in it?
And where should I put it in the file system?

Beginner help much appreciated!

From: Christopher Haupt       Date: 05/29/08 11:23 PM

Subject: RE: .bash_profile

It is ok if you don’t have an existing .bash_profile. You can create a new one and it should be saved in your home directory. If you are in the terminal, this is usually in /Users/yourusername.

If the file is empty, you should put the following in there:

export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

This will get you started.

From: Magnus       Date: 05/29/08 10:22 PM

Subject: I dont have a .bash_profile file

Hello.
I’m very new at the terminal. I dont seem to have at .bash_profile file. Can i make a new one with only this PATH variable in it? And where should it be placed in the filesystem?

From: nate       Date: 04/27/08 11:23 PM

Subject: $ open -e .bash_profile

will open (if it exists) the .bash_profile file in TextEdit. This will be simpler than trying to figure out vi if you don’t already know it. Without the “-e” option, your shell will try to run .bash_profile as a program.

From: Pattie       Date: 04/27/08 10:10 AM

Subject: Can't start up the server

I get to this part:
$ cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &

and then it gives me this output:

5 38397
Macintosh:local Pattie$ Starting mysqld daemon with databases from /opt/local/var/db/mysql5
STOPPING server from pid file /opt/local/var/db/mysql5/Macintosh.local.pid
080427 13:53:13 mysqld ended

any ideas?

From: Vdub       Date: 04/18/08 11:11 AM

Subject: error trying to install mysql

when i type into terminal sudo port install mysql5 +server

i get the error

-> Building zlib with target all
Error: Target org.macports.build returned: shell command ” cd ”/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_archivers_zlib/work/zlib-1.2.3” && make all ” returned error 127
Command output: sh: make: command not found

Error: The following dependencies failed to build: openssl zlib
Error: Status 1 encountered during processing.

From: Snowman11       Date: 04/16/08 05:17 PM

Subject: liquidoz

I read somewhere to type touch .bash_profile to create a file. I did that and added the path and now it works…
In His Service,
Snowman

From: Christopher Haupt       Date: 04/10/08 05:17 PM

Subject: Setting your path

When you first fire up terminal, make sure you are in your home directory. Type (in lowercase) cd and press return. Then, type ls -a (that’s an el). If you don’t have a .bash_profile file, you can create one with touch .bash_profile. You should be able to continue with the open .bash_profile command. If not, you can use “vi”, a command line editor. In vi, if the file already contains a line that starts export PATH=, then move down to just after the = sign and open quote. In vi, the commands for moving are the letter keys hjkl (left, down, up, right). Press i to insert after that quote the following: /opt/local/bin:/opt/local/sbin:. Now, press ctrl-[ (control and open square bracket). Then : (colon), and wq and return. You should be done. Close the terminal window, open a new one, and type set. You should see the PATH variable with your new values. Try to type the command which port. It should be there and you can start using it.

From: liquidoz       Date: 04/10/08 09:09 AM

Subject: This is fantastic! (but)

Thanks to BWA for posting this piece! I’m a new to Mac and RoR, so the level of detail was what I needed. I’m looking forward to what you have planned.

That said, I ran into a problem at
“Fire up the Terminal program and enter the command: $ open .bash_profile”. The file wasn’t found. It seems that I wasn’t the only one (http://trac.macports.org/projects/macports/ticket/13742). Unfortunately, I can’t quite decipher the solution (http://trac.macports.org/projects/macports/browser/branches/release_1_6/base/portmgr/dmg/postflight), I understand what needs to be done…just not sure how. Any suggestions?

 

Join Our List

And we'll let you know when we post major new site updates.

We’ll never share your email address with anyone else.

Related Content
from around the Web

Other Articles


Creative Commons License

This article is licensed under a Creative Commons Attribution-NoDerivs 3.0 License