部署 关于部署 Ruby-China 的问题

bindiry · 2011年11月10日 · 最后由 dreamrise 回复于 2012年03月13日 · 5528 次阅读

最近想学习一下 ROR,找到华顺写的这个开源程序参考,在自己的 ubuntu 上搭建时出现了下面的问题,不知怎么解决:

在执行到 sudo rake assets:precompile 时,出现以下错误: 我用 gem 安装了 thin execjs therubyracer nokogiri -v '1.5.0' 哪位同学帮我解决一下这个问题?

bindiry@bindiry-ubuntu:~/workspace/ruby-china$ sudo rake assets:precompile --trace
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `autodetect'
/usr/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs.rb:4:in `<top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `<top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
/home/bindiry/workspace/ruby-china/config/application.rb:12:in `<top (required)>'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/bindiry/workspace/ruby-china/Rakefile:4:in `<top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/bin/rake:19:in `load'
/usr/bin/rake:19:in `<main>'
bundle install

了木有?

安装 Node.js Asset Pipeline 预编译需要一个 JavaScript Runtime

#1 楼 @Rei 也执行了,我是按照 ReadMe 的步骤执行的,前面的命令都没问题

我的 Ruby 版本是 1.9.2,Rails 是 3.1.1

#2 楼 @huacnlee 好的,谢谢,我来试一下。

  1. 我之前是把 rubyracer 放到 Gemfile 里。是不是因为你只用 gem 装了 rubyracer 而没有放到 Gemfile 里的关系?可以试试看。rubyracer 放 deveopment 组
  2. 更推荐用操作系统自带的 js runtime,mozilla 出品,性能更好。Arch Linux 的话 pacman -S js 就可以了。ubuntu 好像是叫 spidermonkey-bin,apt-cache search 一下 spidermonkey 吧

#2 楼 @huacnlee 安装完 Node.js 后,再运行 rake assets:precompile 出现以下错误:

bindiry@bindiry-ubuntu:~/workspace/ruby-china$ sudo rake assets:precompile
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
/usr/bin/ruby1.9.1 /usr/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
rake aborted!
Failed to connect to a master node at 127.0.0.1:27017

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.9.1 /usr/bin/rake assets:pr...]

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

系统运行 mongodb 没?

#7 楼 @cqpx 加入 therubyracer 到 Gemfile 的 deveopment 组后,还是上面的错误。

然后我运行了 mogngodb 和 redis 后,再运行 rake assets:precompile,还是出现同样的错误。。。

#2 楼 @huacnlee

Failed to connect to a master node at 127.0.0.1:27017

这句是什么意思?是不是我还有某些服务没有开启?

27017 是 mongodb 的端口,报这个错说明无法连上 mongodb 你在命令行打 mongo 看能进去不

#10 楼 @cqpx

可以连接的

bindiry@bindiry-ubuntu:~$ mongo
MongoDB shell version: 2.0.1
connecting to: test
> 

#10 楼 @cqpx 是可以 telnet 到的。。。费解。。

bindiry@bindiry-ubuntu:~$ telnet 127.0.0.1 27017
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

mongodb 和 redis 装起 sudo apt-get install redis-server 但我和楼主一样也是遇到一堆问题...纠结

需要 登录 后方可回复, 如果你还没有账号请 注册新账号