当“需要‘咖啡脚本’”时,无法使用 Ctrl+C 停止 Sinatra
我在 Ubuntu 11.04 64 位上运行 Ruby 1.9.2p180。
我有最简单的 CoffeeScript 示例,使用 Sinatra 运行良好,但当我按 Ctrl+C
快捷键时不会停止。所以每次我都必须kill -9
,这变得相当乏味。
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
views/app.coffee
:
alert 'Foo'
它可以在 Ruby 1.8.7 上运行,只需稍作修改:
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
它也可以运行 在 1.9.2 上,当我删除 require 'coffee-script'
行时,但给了我一个警告:
WARN: tilt autoloading 'coffee_script' in a non thread-safe way; explicit require 'coffee_script' suggested.
Find out that it works when using therubyracer
,但在 node
上失败。 Ubuntu 10.10 存储库中的版本 0.1.97 是唯一的例外。当使用 Natty 的 0.2.6 时,它失败了,并且当使用 nvm 安装最新版本(0.4.8)时,我无法通过 nvm 安装 0.1.97。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无法复制。我在运行 bash 和 Ruby 1.9.2p180 的 Mac(操作系统 10.6.7)上。我也没有收到您的
倾斜
警告。我在使用 The Middleman(基于 Sinatra)或 Rails 3.1 时也没有遇到过这个问题;两者都使用相同的
coffee-script
gem(Tilt 也是如此;我怀疑coffee_script
只是一个拼写错误)。您是否尝试过将所有相关的 gem(sinatra、coffee-script、tilt、execjs)更新到最新版本?您的系统上有什么 JS 环境(例如,您有
node
,还是依赖therubyracer
)?Unable to replicate. I'm on a Mac (OS 10.6.7) running bash and Ruby 1.9.2p180. I don't get your
tilt
warning, either.I also haven't experienced this problem when using The Middleman (Sinatra-based) or Rails 3.1; both use the same
coffee-script
gem (as does Tilt; I suspect thecoffee_script
is just a typo).Have you tried updating all the pertinent gems (sinatra, coffee-script, tilt, execjs) to their latest versions? What JS environment do you have on your system (e.g. do you have
node
, or are you relying ontherubyracer
)?在 Ruby 1.9.2、Sinatra 1.3.2、CoffeeScript 2.2.0 和 Node 0.6.2 上,这种情况不再发生。
On Ruby 1.9.2, Sinatra 1.3.2, CoffeeScript 2.2.0 and Node 0.6.2 this does not occur anymore.