Monday 28 August 2006

netstat

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

Yesterday, I was having problems starting my Ruby on Rails server on port 3000. This morning, I discovered the netstat utility that comes with windows.

netstat -a -b
gives you a list of all running programs along with what port they're using and their process id.

This helped me to find out what was hogging port 3000. In my case the offending process was wcescomm.exe, which is to do with the Windows ActiveSync program, and just removing my PDA from it's dock released the port.

If this doesn't solve it for you, you can use taskkill to forcibly terminate a process. For example, to kill off process id 2420:
taskkill /f /pid 2420



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

Please also visit the Swirrl blog

Sunday 27 August 2006

Errno::EBADF

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

Sometimes, when trying to start my rails server with the usual command:

ruby script/server
I get the following error:

=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-08-27 15:10:09] INFO WEBrick 1.3.1
[2006-08-27 15:10:09] INFO ruby 1.8.4 (2006-04-14) [i386-mswin32]
[2006-08-27 15:10:09] WARN TCPServer Error: Bad file descriptor - bind(2)
c:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Bad file descriptor - bind(2) (Errno::EBADF)
from c:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
from c:/ruby/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
from c:/ruby/lib/ruby/1.8/webrick/server.rb:75:in `listen'
from c:/ruby/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:59:in `dispatch'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:3

I realised that if I started the server on a different port, it worked (although I can't see how the error relates to this) e.g.
ruby script/server -p8000
Sometimes even restarting the computer doesn't solve the problem. Something must be running on port 3000 somtimes, but I can't figure out what! At least using a different port for my server lets me continue working.

UPDATE: See my next post for a way to get round this problem.



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

Tuesday 15 August 2006

Hello

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

Hello! Rich here. Welcome to the Rich Text blog. In here you will find rants and musings mainly on computing and technology but other things may creep in too. Stay tuned.



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

Please also visit the Swirrl blog