我最近開始研究一個我從github克隆的項目。嘗試啓動rails服務器時出現語法錯誤
每次我嘗試啓動rails服務器我得到以下錯誤:
/Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:inload': /Users/thomas/Projects/BillingMiddleware/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError) ...sion_store :cookie_store, key: '_BillingMiddleware_session' ^ from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in
load' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:inload_dependency' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in
load' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:588 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587:ineach' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in
instance_exec' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:inrun' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:55:in
run_initializers' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:ineach' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in
run_initializers' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:136:ininitialize!' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in
send' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:inmethod_missing' from /Users/thomas/Projects/BillingMiddleware/config/environment.rb:5 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in
require' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:inrequire' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in
load_dependency' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:inrequire' from /Users/thomas/Projects/BillingMiddleware/config.ru:4 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in
instance_eval' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:ininitialize' from /Users/thomas/Projects/BillingMiddleware/config.ru:1:in
new' from /Users/thomas/Projects/BillingMiddleware/config.ru:1
我collegue也在致力於該項目,並似乎不啓動服務器的任何問題。他正在運行與我一樣的Ruby,Rails和WeBrick版本。
我試着改變從鍵的語法:鍵=>,這應該不是問題,雖然我運行ruby版本1.9.3。如果我作出這樣的改變,無論如何我得到一個不同的錯誤信息:
/Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load': /Users/thomas/Projects/BillingMiddleware/config/initializers/wrap_parameters.rb:8: syntax error, unexpected ':', expecting kEND (SyntaxError) wrap_parameters format: [:json] ^ from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:588 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587:in `each' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing' from /Users/thomas/Projects/BillingMiddleware/config/environment.rb:5 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' from /Users/thomas/Projects/BillingMiddleware/config.ru:4 from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' from /Users/thomas/Projects/BillingMiddleware/config.ru:1:in `new' from /Users/thomas/Projects/BillingMiddleware/config.ru:1
我已經厭倦了完全拆卸和重新安裝RVM,Ruby和Rails了幾次都沒爲準。我也試過運行捆綁安裝,這沒有幫助。
有沒有人有任何想法出了什麼問題?
謝謝
這似乎是解決問題的快速解決方案。我只是想知道爲什麼當我運行Ruby 1.9.3時,它爲散列值的這種語法抱怨? – MalcolmDurling
你仍然在你的系統中以某種方式使用ruby 1.8.7。至少你已經起來跑步了。祝你好運。 – Anil
許多代碼已經提交給項目,雖然有了新的語法,但是當它爲項目的其他成員工作時,似乎毫無意義地將它們全部更改回舊語法。這是我能嘗試的其他事情嗎?當我運行紅寶石-v我得到 紅寶石1.9.3p194(2012-04-20修訂版35410)[x86_64-darwin11.3.0] 我使用RVM,當我運行rvm列表紅寶石時,我只得到= * ruby-1.9 .3-p194 [x86_64]我也運行rvm使用ruby-1.9.3-p194,這沒有幫助。 – MalcolmDurling