Showing posts with label IDE. Show all posts
Showing posts with label IDE. Show all posts

Thursday, 6 March 2008

Rails on Mac OS X Leopard

Note: The RichText blog has moved to www.ricroberts.com

We'll get to the instructions for setting up rails on Leopard in a moment, but first a bit of background...

A few days after it was released, I changed over to using Mac OS X 10.5 (Leopard) as my platform for developing rails apps. When I first installed Leopard it took me a little while to figure out the best way to do things, as Leopard comes with lots of rails development features pre-installed.

Recently, after reinstalling my OS, I had to figure some of it out again as I hadn't made enough notes. So this time, I thought I'd document it properly and share it on my blog for the benefit of others (and so I don't forget too!).

As you might remember from this post last year, I'm a fan of using Netbeans for my rails IDE. Since that post, it has come out of beta and is now a fully fledged release (currrently at v6.0.1).

However, I couldn't get its step-through debugger to work with Leopard's installation of rails. I think is is because Netbeans assumes certain relative paths between the ruby interpreter and your gems, which differ in the Leopard standard install.

After being inspired by this post by Robby Russell, I decided to use Macports as my solution. Macports gives you a self contained environment for installing stuff. Everything installed under Macports lives in /opt/local, so if you mess up your Macports environment, you can easily just trash this folder and start again.

Installation Procedure


Here goes... The following instructions walk you through how to set up a development environment with Ruby, Rails, MySQL, Netbeans and Subversion on OS X 10.5 "Leopard".

Xcode
Before doing anything else, we need to install the Xcode tools from the Leopard DVD. Just double click on the installer and away it goes.

Macports
Download the installer from the Macports site, and run it.
(I used the dmg for v1.5.0 for OS X 10.5, but I think v1.6.0 is out now so you might want to try that one).

MySQL
Now, for MySQL, I just downloaded the package from the MySQL site, and installed it.

The problem I've found with this using this package is that the preference pane and automatic startup item don't work quite right, but there are workarounds for this. In particular, this worked for me:


"[...] the working MySQL.prefPane is here

and to get the StartupItem to work (see bug#25008), copy the (if existent)
/usr/local/MySQLCOM directory to /Library/StartupItems/MySQLCOM "


There are also some great free GUI tools available on the MySQL site too. At the time of writing, there isn't a dedicated package for these available for OS X 10.5 -only 10.4, but it works fine.

Set paths
This step is important! Dont skip it.

edit ~/.bash_profile, for example using TextMate:
mate ~/.bash_profile

and add the following line:
export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

(As I mentioned before, anything installed in Macports is installed under opt/local)

Save the file, and restart your terminal session to pick up the changes.

Install ruby and rubygems in Macports

sudo port install ruby
sudo port install rb-rubygems


Install all your required gems

For example:

sudo gem install rake
sudo gem install rails
sudo gem install capistrano
sudo gem install termios
sudo gem install mongrel
sudo gem install mongrel_cluster
sudo gem install ruby-debug
sudo gem install ruby-debug-ide


(The ruby-debug and ruby-debug-ide gems above are required if you want step-through debugging to work in Netbeans).

Subversion
I just use the subversion installation that comes with Leopard, as this works fine.

Netbeans
Download Netbeans from here, and run the installer. (For developing rails apps, you just need the 'ruby' bundle).

Debgging in Netbeans
In Netbeans, under Preferences->Ruby, set the ruby interpreter to /opt/local/bin/ruby
The fast debugger radio button should become available - select it.

That's pretty much it. You should now have a fully functioning setup for developing on rails.

Note: I use svn over ssh to access my subversion code repository. Below are some instructions for getting this to work with Netbeans. You can safely ignore all that follows if this doesn't apply to you - Netbeans works fine 'out of the box' with svn over http...

svn+ssh in Netbeans
In order to get the svn+ssh protocol to work with Netbeans, you need to set up a ssh key, and set your mac up to remember it. Here's how to do this

1. Create a pair of keys on your local machine.
From your home directory on your mac, run the following command:
ssh-keygen -t dsa

This will prompt you for a secret passphrase - make sure to use a good passphrase. When this is done you will get two files called id_dsa and id_dsa.pub in your ~/.ssh dir.

2. On your server, ensure that the .ssh directory exists for the user
Log in to your server via ssh
ssh myuser@myserver.net

make a .ssh hidden directory
mkdir ~/.ssh


3. Place your public key on your server
On your mac, run
ssh myuser@myserver.net 'cat >>.ssh/authorized_keys' <~/.ssh/id_dsa.pub


4. Try to log in to the server
ssh myuser@myserver.net


You will be asked for the passphrase

In OS X Leopard, there is a user interface for ssh-agent which will ask you if you want to remember the passphrase, and will store it in your keychain. From then on, you wont need to enter a password or a passphrase for this user.

5. Edit the subversion config
This step is required because, although when you check out from an svn repository in Netbeans, the dialog asks you for a tunnel command, it forgets that when you restart the IDE.

On your mac, edit the ~/.subversion/config file (note: this file wont exist unless you've previously run Netbeans)
mate ~/.subversion/config


Add an entry under the [tunnels] section like this:
ssh = $SVN_SSH ssh -l my_ssh_username

Save the file.

Now, Netbeans will be able to access your svn repository over ssh without needing a password from you.

6. Checkout from your repository
In Netbeans, If you go to the Versioning->Checkout dialog, you will see that the tunnel command is pre-populated for you. Just enter your repository location eg:

svn+ssh://myserver.net/repository

and everything should work fine.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Monday, 10 September 2007

NetBeans Intervenes

Note: The RichText blog has moved to www.ricroberts.com

Regular readers of this blog will know that I'm not averse to trying new IDEs for my rails development.

I recently came across this post by George Cook about an app I hadn't considered.... NetBeans.

George does a great job of explaining NetBeans's virtues, so I won't repeat them all here, but to sum up, it does everything I need a rails IDE to do plus a little bit extra. The most impressive feature for me is the in-IDE fast debugging (more on how to set this up below).

NetBeans does have it's down points. With its default settings it doesn't look as slick as TextMate, but after some fiddling around with the preferences you can rectify this. It does use more memory than TextMate but even on my MacBook with 1GB RAM and lots of other applications open, I still have a little bit free. Besides, compared with something like Microsoft Visual Studio 2005 (which eats RAM for breakfast) NetBeans is a veritable size zero.

There is a ruby-only build of NetBeans available which helps to keep the memory footprint down. The exact version I installed was build 3533, which seems to work fine.

UPDATE (26 Sep 07): Netbeans 6 Beta 1 is now out! Get it from the Sun web-site.

Getting started with NetBeans

Here are few quick pointers to get you going.

To begin, all you have to do is do:
-> File -> New Project
.. and then choose "Ruby on Rails Application with Existing Sources"
and browse for your rails folder.

You need the ruby-debug-ide gem installed (sudo gem install ruby-
debug-ide) to do fast debugging.

Before trying to debug, you need to go to:
-> Preferences -> Ruby -> Platform
... then choose the location of your ruby interpreter (e.g. /usr/local/bin/ruby)
You should then be able to select the Fast Debugger radio button for the
Debugger engine. (If you can't, try restarting NetBeans - this worked for me).



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Monday, 7 May 2007

Aptana with fast debugging

Note: The RichText blog has moved to www.ricroberts.com

I blogged a while back that Radrails was taken over by Aptana. Recently, someone entered a comment on this old post saying that Aptana now supports fast debugging. So I thought I'd give it a whirl.

To get it to work, you need to install the "ruby-debug" gem, the "ruby-debug-ide" gem, and follow these instructions.

This is a very useful feature, although having used TextMate for a while I prefer its clean look over Aptana's rather cluttered feel.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Saturday, 10 March 2007

Radrails and Aptana

Note: The RichText blog has moved to www.ricroberts.com

Earlier this month, I wrote about the demise of Radrails.

Well, Aptana have stepped in to save the day. It's not clear exactly what will become of Radrails in its current form, but anything's got to be better than all of that great work just petering out into obscurity.

Here's what the Radrails site had to say about it all.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Sunday, 4 March 2007

TextMate for rails

Note: The RichText blog has moved to www.ricroberts.com

With the seemingly indefinite postponement of Radrails 0.8, I decided to go on the hunt for another Ruby on Rails IDE.

After scouring the web, I found that many people seem to favour TextMate, and according to this page the core Rails team use it for development, so I thought I'd give it a whirl.

I must say I am impressed. It features Subversion integration, and some built in support for developing Ruby on Rails applications. The only thing it doesn't have is a step-through ruby debugger, but there is a TextMate ruby-debug bundle which allows you to set breakpoints from within TextMate. (My previous blog post explains more about ruby-debug.)

Note that in order to get the Subversion integration to work, you need a Subversion client installed. There are now new instructions on Hivelogic.com for setting up rails on OS X which now feature how to install one.

TextMate is not free, but it is cheap at only 39 Euros.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Fast Ruby debugging

Note: The RichText blog has moved to www.ricroberts.com

Last September I described how to use Radrails for debugging rails apps. I mentioned in that post that it was slow and unresponsive, but bearable.

Today I discovered another way of debugging Ruby On Rails apps, but this time in a much speedier fashion.

Ruby-debug allows you to quickly debug your ruby on rails code. The debugger itself is not integrated into an IDE, but the command line interface is intuitive and adequate.

There is an excellent tutorial on the DataNoise website for how to use ruby-debug. Using this, I was able to get debugging literally within a few minutes.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Thursday, 1 March 2007

Where are Kyle and Matt?

Note: The RichText blog has moved to www.ricroberts.com

The development of Radrails seems to have slowed to a crawl recently, which is a shame as I was eagerly awaiting features promised for version 0.8!

According to posts on the radrails community pages, it looks like the main members of the Radrails team are spending their time on other more profitable ventures.

All the same, for me Radrails is still the best value rails IDE. Some other IDEs have similar features but you have to pay for the privilege.

Where did the Radrails team go
Has Radrails disappeared off the face of the earth



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Friday, 26 January 2007

Setting up rails on OS X (including radrails)

Note: The RichText blog has moved to www.ricroberts.com

Hello. This post documents how to get rails going on Mac OS X (I'm using 10.4.8, by the way).

Well, basically I followed these brilliant instructions on Hivelogic.com (except I used ruby 1.8.5 instead of 1.8.4) and it just worked! The only little quirk was getting the lightTPD web server to work properly. I had to tweak the paths on the first line of the dispatch.cgi, dispatch.fcgi and dispatch.rb files (in the public folder of my rails project) as they were pointing to a windows-style path.

Radrails pretty much just worked "out of the box" too, but to get radrails to start the lightTPD server properly, I set up a symbolic link like this...

ln -s /usr/local/sbin/lighttpd /usr/bin/lighttpd
...as radrails was having trouble finding it initially. (Credit for this last bit goes to Marc from the radrails community). Note that even after this link is setup, the radrails never reports the lightTPD server as 'started' - it just stays as 'starting...', but it does actually seem to start it properly. I also noticed that the lightTPD server starts on the last port you used for it, and it doesn't pay attention to the one that you specify in radrails.

Remember this post from September where I explained how to setup debugging in radrails on Windows XP? Setting up debugging for radrails in OS X is almost exactly the same, but in the interpreter arguments page of the debug dialog you'll want to put something like:

-I"/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/bin"

Also, I had trouble getting debugging to work with lightTPD, so I've put the following in the program arguments to force it to use webrick instead.

webrick -p3001

That's it. enjoy!

UPDATES (March 07):
There are now updated instructions on Hivelogic.com.
You might also want to try Textmate and ruby-debug



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Tuesday, 22 August 2006

Gleaming steel

Note: The RichText blog has moved to www.ricroberts.com

UPDATE (19 Sept 06): Radrails included debugging all along - check out my latest blog entry.

Last week I posted an entry about RoR IDEs and debugging. Since that was written, I have tried out the latest version (0.75) of the free RubyInSteel plug-in for Microsoft Visual Studio from the chaps at SapphireSteel software.

Using the simple articles in their website's online user guide, I successfully managed to import my rails project, and debug rails server methods. (For the record, I am using VS2005 Professional).

Running the server in debug mode was considerably slower than running it normally, taking 3-4 seconds to load each page, but it was much quicker than running Komodo's debugger. My only complaint is that my rails server seemed to randomly stop a couple of times while debugging.

I also managed to successfully install and use the VisualSvn SVN plug-in for Visual Studio. This is not free but cheap at $19, and I found it much better than ankh, which I had previously tried.

To use VisualSvn, you also need to install the Tortoise SVN client, which is available from the VisualSvn download page. Everything was a dream to set up and use - All I did was install everything and it just worked. (It seems to just go off the .svn folders in the directory structure, as I assume all svn clients do. These folders were already there for me, after using RadRails).

Visual Studio 2005 itself has its down-points, such as being RAM-hungry and a little bit buggy in places, but its a mature, effective editor with lots of good features. I also had almost zero learning curve to overcome before starting to edit my RoR code, with me already being very familiar with this IDE.

I think I will use the VS2005-RubyInSteel-VisualSVN combo as my main environment for a while - at least until RadRails includes rails debugging.

Stay tuned to find out if I still feel the same love after using it in anger for a bit!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Wednesday, 16 August 2006

Ruby on Rails IDEs and debugging

Note: The RichText blog has moved to www.ricroberts.com

UPDATE: You might want to have a look at this post for details of using TextMate for Ruby On Rails development, or this post for NetBeans.

I'm primarily a .NET developer in my job but in my spare time I've recently been dabbling in a bit of Ruby on Rails (RoR) development. If you've never heard of it, check out www.rubyonrails.org - Its basically a new-ish web development framework based on the ruby scripting language.

To develop in RoR you don't need an IDE - you can get by with notepad and a console window but I've grown up on Microsoft Visual Studio so I felt the need for one.

So far, I've mainly been using RadRails, which is a pretty neat, free, open-source Ruby On Rails IDE based on Eclipse. This does most things I've needed, such as integrated Subversion source control support, syntax highlighting and various other Rails specific bits and bobs such as starting/stopping the Rails server etc (LightTPD, Mongrel and WEBrick Servers are supported).

However, at the time of writing RadRails is still missing rails debugging capabilities. Rails does come with a console "breakpointer" tool which lets you interrogate variables at certain points in the code, but there's no way of stepping-through rails server code (specifically the "controller" classes), while making requests from a browser, like Visual Studio does for ASP.NET. Apparently debugging will be included in Radrails 0.8, but 0.7 has only just been released and as a relative rails novice I've felt the need for a debugger quite frequently recently.

UPDATE (19 Sept 06): Radrails included debugging all along - check out my latest blog entry.

So, over the last few weeks I've been on a quest to find a decent RoR IDE with debugging, but with which I don't lose anything I've become accustomed to with RadRails, and which doesn't break the bank. This has proved not to be an easy task.

RubyInSteel is a free plug in for Visual Studio, which promised debugging, but after installing it I found that although it can debug ruby script, there is no support for rails debugging. Besides, the only SVN plug in I found for Visual Studio was ankh, which I couldn't get to work very well with my remote SVN repository.
(UPDATE: Since this was originally written, I've tried out the new version of RubyInSteel which does support rails debugging - see my next blog entry).

Arachno is a commercial standalone IDE which supports ruby on rails. This too claims to support rails debugging, and I found instructions in the ruby on rails wiki which detail how to set it up. I followed these instructions to the letter on my trial version of arachno, but to no avail. Maybe it was just lack of familiarity with this app, but I couldn't figure out why debugging wasn't working. The general feel of this IDE is a bit clunky and although it seems like there are lots of features, I wouldn't like to use it as an everyday editor. I never got as far as trying to get SVN to work with this one. Maybe if I can find out where I went wrong with the debugging, I'll give it a go, as arachno is pretty cheap at $49 for the personal version.

Komodo is another commercial standalone IDE supporting RoR, and I actually got this one to debug a controller method by following these very simple instructions. However, running your rails app in debug mode through komodo is very sluggish. For example, my rails server which normally fielded page requests almost instantaneously on my dev-PC sometimes took 30 or more seconds per page under debug mode in komodo.... but, when a breakpoint was actually hit, the IDE seemed to respond fairly well to clicking the step-over/in/out buttons. I also got SVN to integrate OK too, although I had to install a separate svn client - something which you don't need to do in RadRails - and accessing SVN functions caused the IDE to crash on me once. All in all, komodo is quite slick and if it wasn't for the weighty price tag of $295 for the professional edition (you don't get SVN support in the personal edition), I would be very tempted. The jury (me) is still out on this one.

So after all that I think that, in the short term, I'll have a bit more of a play with komodo during my free trial to see if it really justifies spending over 150 pounds. I might just sit it out and wait for RadRails 0.8, as it does everything else so well (and its free!).



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog