Archive for category Mac

gem install mysql on Mac OSX Leopard with RVM

I installed RVM a few months back and messed around with it for a minute, but I did not try out Rails 3 beta with it. I have been researching Rails 3 a good bit lately, and I decide that it would be worth it to upgrade most of my apps to Rails 3, since it has so many appealing new features… especially the plugin API.  I have Ruby 1.8.6 installed on my box and you need a version greater than 1.8.7 (I think) in order to run Rails 3.  RVM is an easy way to run multiple versions of Ruby on the same box without conflicts.   So I fired up my shell and checked to see if RVM was working:

>rvm list

This returned my system ruby and nothing else. So I decided to install 1.9.1

>rvm install 1.9.1

It went thru the process and took a few minutes to download, configure and compile it. After it was complete I fired off this command:

>rvm 1.9.1
>ruby -v

From there I could see that I was in fact using Ruby 1.9.1 instead of 1.8.6 which was originally installed on my Mac. VERY COOL! I proceeded to install rails –pre and everything seemed to be working fine until I created a rails app and did some tests. It was complaining that I needed to install mysql 2.8.1 in order for activerecord to work. Note that in RVM, your gems are installed in a separate directory for each Ruby version that you install. Then I proceeded to install the mysql gem

>gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

/Users/johnmcaliley/.rvm/rubies/ruby-1.9.2-preview3/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir.............yada,yada,yada..........

Damn! I have seen that before.. way back when I first set up my Mac to run Rails 2.3.2. ohh.. so I need to tell it where mysql is. I searched G and found what was working for other people (Note: change -arch to your type system):

>sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
>   --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
>   --with-mysql-include=/usr/local/mysql/include

Doh! Still not working.. I get the same error. So I proceeded to search and search to find the right way to do this. Here are some decent resources I ran across and they may help your particular situation, but nothing seemed to work for me.
http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard
http://adamyoung.net/gem-install-mysql-OSX
http://movesonrails.com/journal/2010/4/21/rvm-installing-the-mysql-gem-ruby-191-under-osx.html(I think there are some typos in this blog and it appears rake-compiler is what you really need at the end)

So after a few hours of wanting to punch my screen, I decided to remove RVM, do a fresh install and try again.

>sudo rvm implode

This should remove RVM and all the files under $HOME/.rvm/
Actually… I did it without sudo first and it removed rvm, but not the .rvm directory under my home… so I had to sudo rm -Rf ~/.rvm

I followed the instructions on the RVM install page and it installed it just fine. This time I installed the lastest version of Ruby which is 1.9.2 (yes I tried that with RVM before I uninstalled it too and it did not work).

>rvm install 1.9.2
>rvm 1.9.2
>sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
>   --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
>   --with-mysql-include=/usr/local/mysql/include

Worked like a charm… So I guess it was something with my original install of RVM. I must have configured it wrong or something.. When all else fails, start from scratch.

Tags: , ,

iTerm closes session immediately after you click the bookmark

I was having this problem yesterday when I was trying to open up a session in iTerm.  I use Rackspace Cloud for my servers and I rebuilt one of the servers with a fresh image.  As it turns out, the SSH key is different when the new server is built even though it has the same IP and almost everything else is the same on the server.  iTerm does not like this and does not even give you an error message.  It just immediately closes the session without any feedback.  In order to correct this you need to go to your mac shell.. hey, might as well use iTerm.  Then you need to edit .ssh/known_hosts in the current user’s home directory.  Remove the line for the IP address that you are having trouble with.  Save the file and try to open the iTerm bookmark again.  It should ask you to accept the new ssh key.  Type ‘yes’ and you are good to go.

Tags:

mini CD stuck in iMac or Macbook

OK, so I reached a new level in stupidity today ;-)

I have some mini CDs with home movies on them and I was planning on putting them on my work iMac for backup.  I thought.. for sure the CD/DVD slot loader can pull in the mini CD.  Macs are supposed to “just work”, right?  So I put it in the drive and its stuck.  After googling a little, I found comments like “its common sense to not put a mini CD in the iMac”  or “YOU ARE AN IDIOT”.  There were a few things that people mentioned like rebooting and holding down some key.. or using the disk utility.  I could not even get the computer to detect that there was anything in there, so it did not give me the option to eject.  So here is my brute force solution:

1. Call the Apple store and listen to them say “ughhhh.. what a moron” under their breath after you explain the problem to them

2. Hang up, because you should have expected he would be a dick

3. Get a regular sized CD and shove it into the drive

4. It will most likely try to mount it, but since the other CD is in there it will fail and push it back out.  Wait until it starts coming out. Push the big CD back a little while its coming out to get some leverage on the mini CD and then jerk it out real quick..  the mini should come out behind it.

5. Go to the Apple store and make your way to the pretentious.. I mean “genius” bar.  Find the guy with the messy hair, 2 day unshaven beard, tight jeans and the dumbass looking 80s shoes and punch him in the face.

6.  If these steps do not work, repeat step #5 just for fun

Tags: ,

su on Mac

I am fairly new to the Mac and I was trying to figure out how to become su when using the Mac terminal. Apparently Mac does not come with su enabled by default.  When I tried the command “su”, it prompted me for a password, but I don’t remember setting a password before.  So in order to get super user access, you have to set the password for root first.  All you need to do is issue this command and you will be able to “su”

>sudo passwd root

Enter your user account password and then enter the new root password twice.  After that issue the “su” command and enter the password you just created.  You have super user access now.