user3726168
user3726168

Reputation: 21

Gemfile syntax error on line 1: syntax error, unexpected tIDENTIFIER, expecting end-of-input

This is my gem file:

source 'https://rubygems.org'

gem 'rails', '3.2.14'
#gem 'jquery-rails', '2.0.2'
#gem 'bootstrap-sass', '2.1'
#gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.11.0'
  gem 'guard-rspec', '1.2.1'
  # gem 'guard-spork', '1.2.0'
  # gem 'childprocess', '0.3.6'
  # gem 'spork', '0.9.2' 
end

group :assets do
  gem 'saas-rails', '3.2.5'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'factory_girl_rails', '4.1.0'
 # gem 'cucumber-rails', '1.2.1', :require => false
 # gem 'database_cleaner', '0.7.0'
  # gem 'launchy', '2.1.0'
  # gem 'rb-fsevent', '0.9.1', :require => false
  # gem 'growl', '1.0.3'
end

group :production do
   gem 'pg', '0.12.2'
end

I keep getting this error

Nicole-DO-NOT-USE:sample_app nicole$ bundle --without production
/Users/nicole/rails_projects/sample_app/Gemfile:1: warning: encountered \r in middle of line, treated as a mere space
Gemfile syntax error on line 1: syntax error, unexpected tIDENTIFIER, expecting end-of-input
#gem 'jque...'3.2.14'ems.org'
...                               ^

When I comment out or delete the lines where the syntax issue is, the same error still appears as if its the 'jquery line'. I checked for white space as well and no luck. Any ideas?

Upvotes: 0

Views: 2132

Answers (1)

mkis
mkis

Reputation: 441

This line in the output is meant to warn you that there is a stray carriage return in your file:

/Users/nicole/rails_projects/sample_app/Gemfile:1: warning: encountered \r in middle of line, treated as a mere space

This can happen for example with files from different operating systems (OS X uses CR, Windows uses CR LF, Unix/Linux uses LF (line feed) to indicate end of line.) You should try converting the file to your operating system's format.

Sublime Text for example has a plugin to do just that: https://github.com/SublimeText/LineEndings

EDIT: A bit more about line endings:

  • \r means "carriage return". It stands for the character Mac OS uses to mark the end of the line.
  • Since the character itself is not visible, "\r" is generally understood to stand for the carriage return character.
  • Unix/Linux uses the "line feed" character for the same purpose
  • Windows uses the combination "carriage return" followed by a "line feed" character to represent line endings.

Read the answers to this question for a more thorough explanation: Difference between CR LF, LF and CR line break types?

Upvotes: 1

Related Questions