Topic: "Rails server" finds syntax error where there shouldn't be one

Hi!

I'm developing an application at two different computers, using Dropbox to synchronize my files. I feel quite sure that the  configuration of rails, ruby, editor and the lot is identical on both computers and up-to-date.
But strangely, when I start the server for testing purposes (with "rails server") on one machine, everything works just fine, while the other machine returns a syntax error (see below).

Does anyone have an idea what the problem could be?
Thanks in advance!

Command-line output:

rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load': d:/Dropbox/sites/suggestMe/config/initializers/session_store.rb:3: syntax error, unexpected ':
', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_suggestMe_session'
                              ^
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.rb:556
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.rb:555:in `each'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.rb:555
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `run_initializers'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `send'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from d:/Dropbox/sites/suggestMe/config/environment.rb:5
        from d:/Dropbox/sites/suggestMe/config.ru:4:in `require'
        from d:/Dropbox/sites/suggestMe/config.ru:4
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/builder.rb:51:in `instance_eval'
        from d:/Rails/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/builder.rb:51:in `initialize'
        from d:/Dropbox/sites/suggestMe/config.ru:1:in `new'
        from d:/Dropbox/sites/suggestMe/config.ru:1

Re: "Rails server" finds syntax error where there shouldn't be one

post the file config/initializers/session_store.rb

check that it is the same on both sites.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: "Rails server" finds syntax error where there shouldn't be one

Checked that! Identical!
Does it matter that the file secret_token.rb is identical on both machines?
Thanks for a fast reply, by the way!


session_store.rb:

# Be sure to restart your server when you modify this file.

SuggestMe::Application.config.session_store :cookie_store, key: '_suggestMe_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# SuggestMe::Application.config.session_store :active_record_store

Re: "Rails server" finds syntax error where there shouldn't be one

Rails.application.config.session_store :cookie_store, :key => "_suggestMe_session"

Now the question, if they are both identical,  why isn't the other one barfing,  because its syntax is wrong also????

Last edited by BradHodges (2011-10-22 20:03:11)

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: "Rails server" finds syntax error where there shouldn't be one

SOLVED.

Obviously, after a lot of strange searches on the net, the solution was always right in front of me:
it seems that deleting the wrapper and session_store files in the folder initializers solves the problem.
Probably every setup wants to create its own version of these files.

Re: "Rails server" finds syntax error where there shouldn't be one

While deleting those fiiles may have worked for you. It isn't the correct solution. As your error output says; you have a syntax error. You are using Ruby 1.8.7, and this file uses the new hash syntax, which Ruby 1.8 doesn't understand, hence the syntax error. The new hash syntax is "key: value" instead of "key => value".

Last edited by ricojones (2012-05-25 10:42:14)