无法启动旧 rails 版本(语法错误)

Can't start old rails version (syntaxError)

我刚刚在 ubuntu 18.04 服务器上导入了一个 5 年前的 rails 项目。我下载了所有要求,例如 ruby 2.0.0 或 rails 3.2.22 和所有的宝石。

目前我正在尝试 运行: rails app:update 这给了我以下错误(当我 运行 rail s 时也是如此):

/usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:81:in `require': /usr/local/rvm/gems/ruby-2.0.0-p648/gems/coverband-5.1.0/lib/coverband.rb:83: syntax error, unexpected '.' (SyntaxError)
    (Rake&.application&.top_level_tasks ...
           ^
        from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:81:in `block (2 levels) in require'
        from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:76:in `each'
        from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:76:in `block in require'
        from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:65:in `each'
        from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler/runtime.rb:65:in `require'
        from /usr/local/rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/bundler.rb:114:in `require'
        from /home/ project/apps/current/config/application.rb:9:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:53:in `require'
        from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:53:in `block in <top (required)>'
        from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:50:in `tap'
        from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/railties-3.2.22.5/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

我尝试 运行 时也出现错误:rake migrate

rake aborted!
SyntaxError: /usr/local/rvm/gems/ruby-2.0.0-p648/gems/coverband-5.1.0/lib/coverb                                        and.rb:83: syntax error, unexpected '.'
    (Rake&.application&.top_level_tasks ...
           ^
/home/ project/apps/current/config/application.rb:9:in `<top (required)>'
/home/ project/apps/current/Rakefile:5:in `require'
/home/ project/apps/current/Rakefile:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:22:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:22:in `<main>'

感谢您的帮助!

在 Ruby 2.3.0 中添加了安全导航运算符 (&.)。

运行 rails app:update 更改的一些代码使用它。

因此您首先需要将 Ruby 版本升级到 2.3.0+。


Rails upgrades and Ruby version requirements