提问人:Syed Sher Ali Hussain 提问时间:10/5/2020 更新时间:10/6/2020 访问量:220
启动 rails 服务器时出错:code&.downcase AND region&.upcase
Error while starting rails server : code&.downcase AND region&.upcase
问:
我正在做一个Ruby on Rails项目。我已经设置好了一切,但是当我尝试通过执行“rails s”来启动服务器时,出现以下错误:
/home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/browser.rb:9:in `require_relative': /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/accept_language.rb:37: syntax error, unexpected '.' (SyntaxError)
code&.downcase
^
/home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/accept_language.rb:44: syntax error, unexpected '.'
region&.upcase
^
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser/browser.rb:9:in `<top (required)>'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser.rb:3:in `require_relative'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/browser-5.1.0/lib/browser.rb:3:in `<top (required)>'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:81:in `require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:81:in `block (2 levels) in require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:76:in `each'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:76:in `block in require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:65:in `each'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler/runtime.rb:65:in `require'
from /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/bundler.rb:114:in `require'
from /home/syed/Desktop/offerletter/config/application.rb:9:in `<top (required)>'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/syed/Desktop/offerletter/vendor/bundle/ruby/2.2.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我尝试过的事情:
- 捆绑安装
- 捆绑包更新
1.Ubuntu 版本 - 20.4 LTS
2.rails - 4.2.2 (由于各种原因不得不维护此版本)
3.ruby - 2.2.2 (由于各种原因不得不维护这个版本)
注意:如果您需要我提供任何进一步的信息来解决问题,请在评论部分询问。
请帮忙。
答:
-1赞
guglielmocg
10/5/2020
#1
如果你被迫使用的 Ruby 版本对于安全导航器 (&.) 来说太旧了,你可以使用老派或使用 try() 方法code.downcase if code
评论
0赞
max
10/6/2020
当代码位于依赖项中而不是在 OP 应用程序代码中时,这有什么真正帮助?
0赞
Swapnil Kumawat
10/6/2020
#2
安全导航器 (&.) 是在 Ruby 2.3.0 中引入的,而您使用的是 Ruby 2.2.0。
请使用方法或将 Ruby 版本升级到 2.3.0+ 以使用安全导航器。try
评论
Ruby 2.3.0
Ruby 2.2.2
2.3.0+
browser
s.required_ruby_version = ">= 2.3.0"