【问题标题】:Why isn't the rails server working? [duplicate]为什么rails服务器不工作? [复制]
【发布时间】:2015-09-10 15:46:16
【问题描述】:

以下是我运行 rails server 命令后终端给我的响应。我在 Linux Ubuntu 上

/home/tor/.rvm/gems/ruby-2.0.0-p643/gems/execjs-2.5.2/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 /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/execjs-2.5.2/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/execjs-2.5.2/lib/execjs.rb:4:in `<top (required)>'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/uglifier-2.7.1/lib/uglifier.rb:3:in `require'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/uglifier-2.7.1/lib/uglifier.rb:3:in `<top (required)>'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler/runtime.rb:76:in `require'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler/runtime.rb:72:in `each'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler/runtime.rb:72:in `block in require'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler/runtime.rb:61:in `each'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler/runtime.rb:61:in `require'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.10.4/lib/bundler.rb:134:in `require'
    from /home/tor/Desktop/hello/config/application.rb:7:in `<top (required)>'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `require'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
    from /home/tor/Desktop/hello/bin/rails:8:in `require'
    from /home/tor/Desktop/hello/bin/rails:8:in `<top (required)>'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `load'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `call'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/lib/spring/client/command.rb:7:in `call'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/lib/spring/client.rb:26:in `run'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/bin/spring:48:in `<top (required)>'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `load'
    from /home/tor/.rvm/gems/ruby-2.0.0-p643/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `<top (required)>'
    from /home/tor/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/tor/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/tor/Desktop/hello/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

【问题讨论】:

  • 正如它所说,找不到 js 运行时。所以安装一个。 rubyracer 通过 rails 包含在 Gemfile 中,取消注释并再次捆绑。

标签: ruby-on-rails


【解决方案1】:

找不到 JavaScript 运行时。有关可用运行时的列表,请参阅 https://github.com/rails/execjs

答案在您的错误信息中,您需要从列出的页面安装 JS 运行时。

【讨论】:

    【解决方案2】:

    在您的 Gemfile 中取消注释 therubyracer

    gem 'therubyracer'
    

    那么你将不得不这样做

    bundle install
    

    【讨论】:

      【解决方案3】:

      添加这些宝石:

      gem 'therubyracer'
      gem 'execjs'
      

      然后运行bundle install

      【讨论】:

        猜你喜欢
        • 2015-03-09
        • 1970-01-01
        • 2015-10-08
        • 1970-01-01
        • 2016-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多