Gemfile语法错误

时间:2013-03-12 23:23:35

标签: ruby-on-rails syntax gem

我收到以下错误:Gemfile语法错误。

这是我的代码:

source 'https://rubygems.org'

gem 'rails', '3.2.1'

gem 'devise'

# Bundle bootstrap gems
group :development do
  gem 'thin'

  # Bundle edge Rails instead:
  # gem 'rails', :git => 'git://github.com/rails/rails.git'

  gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

3 个答案:

答案 0 :(得分:10)

{1}}中的end遗漏了do。在group :development之后的行上添加end语句。

您可以运行gem 'sqlite3'来检查语法(它是常规的Ruby代码),它会让您了解错误的位置。

答案 1 :(得分:1)

看起来你在development组之后错过了一个结局。

答案 2 :(得分:1)

我多次遇到错误,但是我没有触及rails生成的文件,而ruby -c Gemfile表示语法正常。在我的情况下,如果找不到rails命令,可能会报告Gemfile语法错误。

我使用brew + rbenv + ruby​​ 2.0 + rails 4,我使用以下命令使事情恢复正常。

# new commands in brew-installed ruby might not be linked automatically 
brew unlink ruby && brew link ruby 
# fix "gem" itself
sudo gem update --system
# after installing executable with rbenv, you need rehash
rbenv rehash