ROR - rake资产:预编译失败,'CoffeeScript未定义'

时间:2013-05-15 22:17:05

标签: ruby-on-rails rake capistrano

您好我是Rails的新手,我刚刚在Ubuntu 12.04上使用RVM设置了一个生产环境。如果重要,我已经在多用户模式下安装了ruby(rvm位于/ usr / local / rvm / bin / rvm中)。

我正在设置Capistrano来部署我的rails应用程序。除了包含任何CoffeeScript文件之外,一切都很好。作为部署过程的一部分,Capistrano运行rake资产:预编译。这在我的本地环境(osx)上运行得很好但在我的ubuntu上失败了。我已经安装了我认为我需要的所有宝石(咖啡脚本咖啡脚本来源)。但它仍然无效。这里有什么指示?

  * executing "cd -- /var/www/appname/releases/20130515220819 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
    servers: ["1.2.3.4"]
    [1.2.3.4] executing command
*** [err :: 1.2.3.4] rake aborted!
*** [err :: 1.2.3.4] ReferenceError: CoffeeScript is not defined
*** [err :: 1.2.3.4] (in /var/www/appname/releases/20130515220819/app/assets/javascripts/email_tests.js.coffee)
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:68:in `extract_result'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:28:in `block in exec'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:41:in `compile_to_tempfile'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:27:in `exec'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:19:in `eval'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:33:in `call'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/coffee-script-2.2.0/lib/coffee_script.rb:57:in `compile'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/tilt-1.3.7/lib/tilt/coffee.rb:46:in `evaluate'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/tilt-1.3.7/lib/tilt/template.rb:77:in `render'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
*** [err :: 1.2.3.4] /usr/local/rvm/gems/ruby-1.9.3-p429/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'

2 个答案:

答案 0 :(得分:1)

尝试将此添加到您的Gemfile:

gem "therubyracer"

根据我的经验,Ubuntu需要JavaScript解释器,而不是OSX。

希望这有帮助!

答案 1 :(得分:0)

所以经过多次挖掘,我意识到这个文件有0个长度:

/usr/local/rvm/gems/ruby-1.9.3-p429/gems/coffee-script-source-1.6.2/lib/coffee_script/coffee-script.js

这是通过从普通用户运行它来解决的:

rvmsudo gem pristine --all

我在互联网上四处看看,我是唯一一个有这个特定错误的人。我不知道这个文件是如何被截断的。我希望这有助于其他人。