新手问题 跪求各位大神关于 Rails 启动的问题

ghn645568344 · 2015年09月17日 · 最后由 ghn645568344 回复于 2015年09月18日 · 2911 次阅读

使用 rails new dvd 建立的项目 用 bundle install 提示

Using tilt 2.0.1
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using spring 1.4.0
Using turbolinks 2.5.3
Using uglifier 2.7.2
Using web-console 2.2.1
Bundle complete! 12 Gemfile dependencies, 53 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

然后使用 rails s 启动 报错

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/app_rails_loader.rb:39: warning: Insecure world writable dir /home/sang/.rvm/bin in PATH, mode 040777
/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /home/sang/.rvm/bin in PATH, mode 040777
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:76:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:72:in `each'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:72:in `block in require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:61:in `each'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:61:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler.rb:134:in `require'
    from /home/sang/haonan_file/dvd/bpdvds/dp520/config/application.rb:7:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
    from /home/sang/haonan_file/dvd/bpdvds/dp520/bin/rails:8:in `require'
    from /home/sang/haonan_file/dvd/bpdvds/dp520/bin/rails:8:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/lib/spring/client/rails.rb:28:in `load'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/lib/spring/client/rails.rb:28:in `call'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/lib/spring/client/command.rb:7:in `call'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/lib/spring/client.rb:28:in `run'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/bin/spring:49:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/lib/spring/binstub.rb:11:in `load'
    from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.4.0/lib/spring/binstub.rb:11:in `<top (required)>'
    from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/sang/haonan_file/dvd/bpdvds/dp520/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

apt-get install nodejs

这个可以从 log 看出问题。

/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

没有安装 JavaScript runtime, 可在这里 https://github.com/rails/execjs 挑一个,建议安装 nodejs

我自己是用 therubyracer 的。

#3 楼 @msg7086 哈哈,小洁癖,不过我也喜欢这么做。

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