Can’t stop Sinatra using Ctrl+C when `require ‘coffee-script’`

Problem

I’m running Ruby 1.9.2p180 on Ubuntu 11.04 64-bit.

I have the simplest possible CoffeeScript example using Sinatra which runs fine, but doesn’t stop when I press the Ctrl+C shortcut. So every time I have to kill -9 and it's getting quite tedious.

The app.rb:

require 'sinatra'
require 'coffee-script'

get '/' do
'<script src="/app.js" type="text/javascript"></script>'
end

get '/app.js' do
coffee :app
end

The views/app.coffee:

alert 'Foo'

It works on Ruby 1.8.7 with minor modifications:

require 'rubygems'
require 'sinatra'
require 'coffee-script'
require 'json'

get '/' do
'<script src="/app.js" type="text/javascript"></script>'
end

get '/app.js' do
coffee :app
end

It also works on 1.9.2 when I remove the line require 'coffee-script', but gives me a warning:

WARN: tilt autoloading 'coffee_script' in a non thread-safe way; explicit require 'coffee_script' suggested.

Figured out that it works when using therubyracer, but fails on node. The version 0.1.97 from Ubuntu 10.10 repositories is the only exception. When using the 0.2.6 from Natty, it fails and also when installing the latest (0.4.8) using nvm, I wasn't able to install 0.1.97 via nvm.

Problem courtesy of: hleinone

Solution

On Ruby 1.9.2, Sinatra 1.3.2, CoffeeScript 2.2.0 and Node 0.6.2 this does not occur anymore.

Solution courtesy of: hleinone

View additional discussion.