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

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

最近想学习一下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>'
共收到 14 条回复
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 但我和楼主一样也是遇到一堆问题...纠结

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