第1行Gemfile语法错误:语法错误、意外的标识符、预期输入结束

时间:2020-11-26 22:46:45

This is my gem file:

这是我的gem文件:

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?

当我注释掉或删除语法问题所在的行时,同样的错误仍然会出现,就好像它是“jquery行”。我也检查了空格,但没有运气。什么好主意吗?

1 个解决方案

#1


1  

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.

这可能发生在不同操作系统的文件上(OS X使用CR, Windows使用CR LF, Unix/Linux使用LF(换行)来表示行结束。)您应该尝试将文件转换为操作系统的格式。

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

举个例子,崇高的文本有一个插件可以做到这一点:https://github.com/sublimetext/lineending

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.
  • \ r意味着“回车”。它代表了Mac OS用来标记这条线的末端的字符。
  • Since the character itself is not visible, "\r" is generally understood to stand for the carriage return character.
  • 由于字符本身不可见,“\r”通常被理解为表示回车字符。
  • Unix/Linux uses the "line feed" character for the same purpose
  • Unix/Linux使用“换行”字符来实现相同的目的
  • Windows uses the combination "carriage return" followed by a "line feed" character to represent line endings.
  • Windows使用组合“回车”和“换行”字符来表示行尾。

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

请阅读问题的答案,以获得更全面的解释:CR LF、LF和CR断行类型之间的差异?

#1


1  

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.

这可能发生在不同操作系统的文件上(OS X使用CR, Windows使用CR LF, Unix/Linux使用LF(换行)来表示行结束。)您应该尝试将文件转换为操作系统的格式。

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

举个例子,崇高的文本有一个插件可以做到这一点:https://github.com/sublimetext/lineending

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.
  • \ r意味着“回车”。它代表了Mac OS用来标记这条线的末端的字符。
  • Since the character itself is not visible, "\r" is generally understood to stand for the carriage return character.
  • 由于字符本身不可见,“\r”通常被理解为表示回车字符。
  • Unix/Linux uses the "line feed" character for the same purpose
  • Unix/Linux使用“换行”字符来实现相同的目的
  • Windows uses the combination "carriage return" followed by a "line feed" character to represent line endings.
  • Windows使用组合“回车”和“换行”字符来表示行尾。

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

请阅读问题的答案,以获得更全面的解释:CR LF、LF和CR断行类型之间的差异?