当前位置: 首页 > 知识库问答 >
问题:

尝试启动rails服务器时出现语法错误

彭弘方
2023-03-14

我最近开始从事一个从github克隆的项目。

每次尝试启动rails服务器时,都会出现以下错误:

 
/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/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:inload'
    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:inload'
    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:ininstance_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:inrun_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:inrun_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:insend'
    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:inrequire'
    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:inload_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:ininstance_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:innew'
    from /Users/thomas/Projects/BillingMiddleware/config.ru:1

我的同事也在做这个项目,启动服务器似乎没有任何问题。他正在运行和我一样版本的ruby,rails和WeBrick。

我已尝试将语法从key:更改为:key=

/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,但都没有成功。我也尝试过运行bundle安装,但没有任何帮助。

有人知道出了什么问题吗?

谢谢

共有2个答案

吉鸿宝
2023-03-14

看起来像是另一行上的散列语法,在您修复该行之后。检查config/initializers/wrap\u参数。rb我想知道这个项目是否得到了“不”使用新语法的标志?

薛文斌
2023-03-14

尝试将哈希值更改为:key=

App::Application.config.session_store :cookie_store, :key => '_BillingMiddleware_session'

配置/初始化器/wrap_parameters.rb

ActionController::Base.wrap_parameters :format => [:json]
 类似资料:
  • 我刚刚安装了Ruby193和Ruby200,在创建了一个新的应用程序之后,我正在尝试加载服务器,但是我得到了下面的错误。 我用gem'sqlite3'替换了sqlite3 gem,'~ 有人知道怎么修吗? Gemfile是 Bundle Show提供捆绑包中包含的宝石: actionmailer(3.2.13) actionpack(3.2.13) activemodel(3.2.13) acti

  • 我一直在忙着用angularjs前端构建一个REST应用程序,使用MAVEN jersey-quickstart-webapp,使用GLASSFISH WebServer在Eclipse上开发。今天当我开始在项目上做一些开发时,当我尝试在eclipse中启动服务器并部署webapp时,我得到了eclipse错误窗口中显示的以下错误消息: 需要注意的是,我并没有故意更改Eclipse或GlassFi

  • 我是RubyonRails的新手,这里我尝试在64位Windows7上安装RubyonRails。 运行命令后,我执行了,然后执行。但随后我在命令提示符下出错了。 如何解决此错误? 如果我运行bundle安装,我将

  • 问题内容: 我已经安装了rails和mysql。我还安装了mysql2 gem。我通过命令rails new try_cms -d mysql创建了Rails应用程序。创建成功。但是,当我尝试使用rails server命令运行WEBrick服务器时,出现以下错误。 提前致谢。 问题答案: 尝试运行此命令(在此处查看类似的问题)

  • 我遇到这个问题已经有一段时间了,但没有找到解决方案。我正在rails中构建一个论坛应用程序。我刚刚完成将bootstrap和bootstrap gem添加到我的项目中。我去运行服务器,它以一个巨大的错误退出。在这里。

  • 问题内容: 我刚刚完成了重新安装操作系统的工作,并且像往常一样安装和测试了我使用的标准工具,现在当我尝试从eclipse启动Jboss 5时,出现了前所未有的错误: 以前有没有人遇到过类似的问题?到目前为止我从未遇到过 问题答案: 看起来像是JRE和OS版本的某些特定组合发生的错误(请参阅https://jira.jboss.org/jira/browse/JBAS-6981)。基本上,JBoss