Ruby on rails - 启动旧项目时出错

时间:2017-03-02 08:51:37

标签: ruby-on-rails ruby

我有一个2015年的RoR项目,我想要运行。由于我重新安装了系统,因此我使用docker机器尝试启动我的项目。但我有错误,可能需要一段时间才能使其正常工作。这是我现在遇到的错误:

安装时我有这样的消息:

...

Installing devise 3.4.1
Bundle complete! 17 Gemfile dependencies, 66 gems now installed.
Bundled gems are installed into /usr/local/bundle.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

    <= 1.8.6 : unsupported
     = 1.8.7 : gem install rdoc-data; rdoc-data --install
     = 1.9.1 : gem install rdoc-data; rdoc-data --install
    >= 1.9.2 : nothing to do! Yay!
     ---> 71231202532c

当我尝试运行rails s时,我就去了

/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/bundle/gems/execjs-2.5.2/lib/execjs/runtimes.rb:48:in `autodetect'
/usr/local/bundle/gems/execjs-2.5.2/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/bundle/gems/execjs-2.5.2/lib/execjs.rb:4:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/usr/local/bundle/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/bundle/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/bundle/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/usr/local/bundle/gems/uglifier-2.7.1/lib/uglifier.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:91:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:86:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:86:in `block in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:75:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:75:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler.rb:107:in `require'
/config/application.rb:7:in `<top (required)>'
/usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require'
/usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
/usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
/usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
/usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
/usr/local/bundle/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
/bin/rails:9:in `require'
/bin/rails:9:in `<top (required)>'
/usr/local/bundle/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
/usr/local/bundle/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
/usr/local/bundle/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
/usr/local/bundle/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
/usr/local/bundle/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
/usr/local/bundle/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
/usr/local/bundle/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
/bin/spring:15:in `require'
/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Bundler Error Backtrace:
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:86:in `each'
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:86:in `block in require'
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:75:in `each'
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:75:in `require'
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler.rb:107:in `require'
        from /config/application.rb:7:in `<top (required)>'
        from /usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require'
        from /usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
        from /usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from /usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
        from /usr/local/bundle/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /usr/local/bundle/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
        from /bin/rails:9:in `require'
        from /bin/rails:9:in `<top (required)>'
        from /usr/local/bundle/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
        from /usr/local/bundle/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
        from /usr/local/bundle/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
        from /usr/local/bundle/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
        from /usr/local/bundle/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
        from /usr/local/bundle/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
        from /usr/local/bundle/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
        from /bin/spring:15:in `require'
        from /bin/spring:15:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'
  1. 是否可以运行这样的旧项目?
  2. 若然后如何解决这个问题?
  3. 注意 我的rails和gem版本是:

    root@9458e9247409:/# rails -v
    Array values in the parameter to `Gem.paths=` are deprecated.
    Please use a String or nil.
    An Array ({"GEM_PATH"=>["/usr/local/bundle"]}) was passed in from bin/rails:3:in `load'
    Rails 4.2.1
    root@9458e9247409:/# gem -v
    2.6.10
    

2 个答案:

答案 0 :(得分:3)

我猜你在系统上错过了nodejsUglifierJS wrapper,需要JS runtime正在运行或JS interpreter。 请运行以下命令:

on ubuntu

sudo apt-get install nodejs

或为OSX运行

brew install nodejs

答案 1 :(得分:0)

错误不言而喻。 Execjs需要一个javascript运行时引擎而你没有安装。

Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.

检查here以获取可用运行时列表。我建议安装Node.js.