So I came across this question ( Syntax error when creating a Rails model ) which has an error similar to mine. I am deducing from it that my problem is using Ruby 1.8 instead of 1.9. I tried uninstalling the gems and updating rubygems as described in one of the answers, but that did not fix the issue. I also tried setting the default ruby via rvm to 1.9 – it works but it does not solve the issue.
When I run “gem env” I get the following:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/owner/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
In usr/bin I have a “ruby” which is a symlink to usr/bin/ruby1.9.1.
Basically, I need to know how to change the ruby being used here (at least I think that will solve my issue).
My OS is Linux Mint 12.
Rails –version returns “Rails 3.2.3”
My full error is below (from running “rails s” in project directory):
=> Booting WEBrick
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load': /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_sample_app_session'
^
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:588
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:587:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:587
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config/environment.rb:5
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:4:in `require'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:4
from /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:1:in `new'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:1
My gemfile is:
source 'https://rubygems.org'
gem 'rails'
gem 'bootstrap-sass'
gem 'tilt'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
group :development do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails'
gem 'guard-rspec', '0.5.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'rspec-rails'
gem 'capybara', '1.1.2'
# System-dependent gems# Test gems on Windows
group :test do
gem 'rspec-rails'
gem 'capybara', '1.1.2'
gem 'rb-fchange', '0.0.5'
gem 'rb-notifu', '0.0.4'
end
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
end
group :production do
gem 'pg', '0.12.2'
end
PATH:
echo $PATH
/usr/bin/rubycurrent:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
“which ruby” returns:
/usr/bin/rubycurrent/ruby
So I finally figure it out. Here’s what I did.
First, to troubleshoot I uninstalled ruby 1.8. After that I tried running rails s again and got the following error:
When I checked /usr/local/bin/rails script I saw it was including /usr/bin/ruby1.8 at the top. After trying tons of different things to get it working, the only thing that worked was uninstalling ruby, rubygems, rails, and rvm, and reinstalling them all (I had to do this several times… finally it worked one time).
You can try what is listed below to see if it works for you:
http://fatal-errors.com/ubuntu-10-ruby-1-9-rails-3-not-working-solved/99008.