Posts filed under 'ruby on rails'

fixing webrick error - WARN TCPServer Error: Bad file descriptor - bind(2) - on windows

I was working on a Ruby on Rails project with Netbeans today when I went to fire up webbrick to test something in the app.

I immediately got an error like this

=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
[2008-03-18 16:36:59] INFO  WEBrick 1.3.1
=> Ctrl-C to shutdown server; call with --help for options
[2008-03-18 16:36:59] INFO  ruby 1.8.6 (2007-03-13) [i386-mswin32]
[2008-03-18 16:36:59] 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 `new'
        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 `each'
        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.2.3/lib/webrick_server.rb:58:in `new'
         ... 7 levels...
        from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
        from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from script/server:3

I did a quick google of the error, and the general consensus was that something was blocking port 3000.
But when I used the “netstat” command at the command line, I didn’t see anything on the port …

netstat command

I was scratching my head a bit, but I went in to look at what processes were running and I discovered this ruby process …

ruby process in windows

Remember, webrick wasn’t running at this point, because it kept erroring out.
I figured that this was my problem, and on further prodding with Process Explorer, I found …

ruby process blocking port 3000

So I just killed the process and all was well with the universe :)

webrick works again

1 comment March 13th, 2008

Apparently the creator of Ruby on Rails doesn’t comment his code … kinda

Here’s some excerpts from DHH’s post and comments yesterday on 37 signals

  • The short answer is that we don’t document our projects. At least not in the traditional sense of writing a tome that exists outside of the code base that somebody new to a project would go read …
  • Further more, I don’t really find it necessary for the kind of work that we do. Our biggest product, Basecamp, is about 10,000 lines of code. That really isn’t a whole lot in the grand scheme of things. Everything we do is build is also using Ruby on Rails, which means that most Rails programmers would know their way around our applications straight away. It’s the same conventions and patterns used throughout.
  •  Finally, we write our application in a wonderfully expressive and succinct programming language like Ruby that leads itself very well to a programming style like the one Kent Beck preaches in Smalltalk Best Practice Patterns. Keep your methods short and expressive. On average, our models have methods just four lines long. Adding documentation to a method should usually only be done when you’re doing something non-obvious that can’t be rewritten in an obvious way.
  • [comment] Wim, yes there’s RDoc. I just generally don’t use it for projects. When methods are only an average of 4 lines long written in a language like Ruby, it’s often faster and better to merely browse the code base rather than rely on explicit commenting.

Keep in mind that I’m no Ruby on Rails genius, and from the little I’ve done I can see where DHH is going with this. But I’ve always thought that this argument of a language being so succinct and clear that you don’t have to write comments is just a bit silly for a couple of reasons.

  • I believe that you don’t write code for machines, you write code for people (other developers). So any help you can give them in navigating your code is typically good to have. It saves them time and their employers money … that is what being a great consultant is about, you have to be thinking in terms of how to help your clients’ business and saving them money falls in that category.
  • People who use this line of argument are either too lazy to comment and are trying to justify it …
  • … or don’t understand that there are developers of all skill levels in the industry. So whereas, someone with your skill level would be able to navigate your code quickly, someone who wasn’t as good might take longer …why not avoid that.

Note, that I’m not of the school of thought of commenting just for the sake of it, like I’ve heard some “blub programmers” do. However, I do think that you should always be thinking of other developers when you code and if commenting can get them to a point where they can modify your code in 1 minute instead of a minute and a half … then you should comment.

In the end, I guess its a bit unfair to criticize DHH, because its not clear that he doesn’t comment his code much … though its easy to infer that. I just know from my experience that people who say things like he says have a tendency to have 3 lines of comments in some piece of code 500 lines long.

But if you’re a “rockstar developer, I guess everyone has to dance to your tune, wherever you are right?

Add comment February 6th, 2008

Ruby reddit and top ten list of Ruby gems!

Quick note to say that  I just discovered the brand new Ruby Reddit which is really fortuitous now that I’m spending a lot of time with Ruby on Rails. From there I found the “Ten Essential Ruby Gems” … which I am installing and screwing with as I type :]

Many thanks  to Reginald Braithwaite who runs the immensely popular software development blog Raganwald for his post about the Ruby Reddit.

Add comment February 1st, 2008

random dude on the “internets” disembowels Ruby on Rails …

I spent the whole weekend reading about Rails setup and deployment, discovering Ngnix + mongrels as a new Rails hosting setup option and started getting in depth with Rails with Obie Hernandez’s “The Rails Way“.

I don’t know much about the guts of PHP or Rails (that is something I am working very hard to remedy) but I was fascinated by this google group post  “Rails is shitty” … [here is the precursor to it] even though my first thought is that it contains a lot of the same elitist arguments that were aimed against PHP years ago (PHP is still wildly successful) I do think its raises interesting points and things for me to look out in in my exploration of Rails.

I wonder if DHH (aka God) will respond to this.

Here’s a sample

And to stress the first point again, Rails never concerns itself with
the big-picture problem of “writing webapps”. It only thinks as big as
“outputting HTML strings” and “querying the DB for a list of things”.
This means the important, actually hard stuff like handling the stateless
nature of HTTP, or sanitising and escaping the user input is just not
adressed at all, and you only learn about them when one day you discover
84 possible XSS injection points (actual number from a Rails app I’m
somewhat famililar with)

Add comment January 21st, 2008

Is rails a ghetto? developments in the ROR space.

Although I haven’t done as much work with Rails as I’d like, I follow it very closely because I like the language and the platform, plus I’m sure to write a web application in it in the next month or two.

In the last few weeks, though,  there have been some interesting developments in the ROR space. Ace programmer Zed Shaw fired two broadsides against the Rails community a few weeks back titled Rails is a ghetto. [aside: there is this very interesting O'Reilly interview with Zed that might help you understand his accomplishments with Ruby]

Its an interesting read, albeit unprofessional and rather profane. I came away from the two part rant feeling that if Mr. Shaw were as unprofessional as he sounded, then it might be the reason he kept bumping into the types of characters he “railed” against. I also didn’t get enough evidence from the rant to really justify (in my mind at least) that the Rails community was a ghetto. It just seems that the immediate space that Zed seems to work in was a bit crappy but the job postings I see for Rails are an order of magnitude more coherent and well-mannered than the ones I see for php. Anecdotal … I know.

Obie Hernandez, another big time Rails person (author of the book “The Rails way”) posted a very balanced counter point to the ghetto rant … About Rails and Ghettos. I felt this was a better assessment of the community. This is my perspective as a one-foot-in-one-foot-out guy in relation to Rails.

The second episode concerns the mounting concern with Ruby on Rails performance and ease of deployment. In case you don’t know, Ruby is slow and painful to deploy. (I helped a client with a Ruby on Rails application deployment late last year and the experience was not pleasant). Dreamhost offers Ruby on Rails hosting for its shared server accounts, and in this post “How Ruby on Rails could be much better” they outline the problems they have had hosting Ruby on Rails and gives suggestions for making it better.

To this, the creator of Ruby on Rails responded with “The deal with shared hosts” which I think shows a disregard for the importance of shared hosting accounts and a bit of his brashness. In summary.

In exchange, I’ll ask a few, small favors. Don’t treat the current Rails community as your unpaid vendor. Wipe the wah-wah tears off your chin and retract the threats of imminent calamity if we don’t drop everything we’re doing to pursue your needs. Stop assuming that it’s either a “complete lack of understanding of how web hosting works, or an utter disregard for the real world” that we’re not working on issues that would benefit your business.

[aside: I kind of agree with this, Dreamhost should hire someone to actually get under the hood and make Rails work for them, after all they are making money off of it. I just think the tone is a tad arrogant]. To continue, Dreamhost wrote another post “Rails is as Rails does“, softening their tone but still making the excellent point that making Rails easy to deploy can only win it converts. Somehow, I don’t think the Rails folks really care about converts that much (the interesting question is “Do they need to?”). Apple thrives on that air of exclusivity that its products high prices give it, maybe Rails is targeting elite programmers who don’t complain but fix what they don’t like and get on with it.

At at the end of all this though, I am left with a weird taste in my mouth about Ruby on Rails. I’ve always felt that Rails folks are a bit arrogant and condescending. I think there is the feeling that everyone should develop with ROR a certain way and if you don’t, you’re not worth wasting time on. In fact here is the creator’s message to people who have a problem with the way he handles Rails, (with some background so you don’t think I’m being unfair) …

if you don’t like the way I’m creating Rails then fuck you.

I see where they’re coming from, but I’m not sure I like it. I love Ruby, I have the best Ruby on Rails IDE installed and hope to be knee deep in it soon. It will be interesting to see if the impressions I have formed about the community hold up.

Add comment January 20th, 2008

Next Posts


Recommended

Posts by Category

Calendar

January 2009
S M T W T F S
« Dec    
 123
45678910
11121314151617
18192021222324
25262728293031

Posts by Month