部署capistrano时为什么会出现语法错误?

时间:2019-06-06 09:19:55

标签: ruby capistrano

我是capistrano和ruby的新手,使用cap deploy时遇到一些错误。我试图升级我的ruby版本和io-console,但是它们都没有帮助我解决问题。有人可以帮我解决吗?

在我的错误日志下面:

/usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': /usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n/exceptions.rb:20: syntax error, unexpected <<, expecting ')' (SyntaxError)
      super(<<~MESSAGE)
              ^
/usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n/exceptions.rb:23: syntax error, unexpected keyword_in, expecting keyword_end
...hod is meant to display text in the user locale, so calling ...
...                               ^
/usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n/exceptions.rb:23: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
... in the user locale, so calling it before the user locale has
...                               ^
/usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n/exceptions.rb:26: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
...tside of the user flow, you can do so by passing
...                               ^
/usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n/exceptions.rb:27: syntax error, unexpected tIDENTIFIER, expecting keyword_end
...ctly with the `locale` argument, e.g. `I18n.#{method}(..., l...
...                               ^
/usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n/exceptions.rb:27: syntax error, unexpected tCONSTANT, expecting :: or '[' or '.'
...e `locale` argument, e.g. `I18n.#{method}(..., locale: :en)`
...                               ^
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/ruby/gems/2.0/gems/i18n-1.6.0/lib/i18n.rb:6:in `<top (required)>'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/ruby/gems/2.0/gems/capistrano-3.11.0/lib/capistrano/i18n.rb:1:in `<top (required)>'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/ruby/gems/2.0/gems/capistrano-3.11.0/lib/capistrano/all.rb:10:in `<top (required)>'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/ruby/gems/2.0/gems/capistrano-3.11.0/bin/cap:2:in `<top (required)>'
        from /usr/local/bin/cap:23:in `load'
        from /usr/local/bin/cap:23:in `<main>'```


1 个答案:

答案 0 :(得分:3)

错误消息的路径看起来像您正在使用2.0 gem的Ruby 1.6.0和版本i18ni18n gem在该版本中使用弯曲的Heredoc语法(<<~)。语法是在Ruby 2.3中引入的。

这意味着您有两个选择:

  • 将您的Ruby版本至少更新为2.3
  • 降级i18n1.5.1似乎是不依赖Ruby 2.3的最新版本