2

我收到以下错误: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'
4

3 回答 3

10

你缺少一个endfor the doin group :development。在 . 之后的行上添加一条end语句gem 'sqlite3'

您可以运行ruby -c Gemfile以检查语法(它是常规的 Ruby 代码),它会让您了解错误所在。

于 2013-03-12T23:27:06.897 回答
1

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

于 2013-03-12T23:25:53.373 回答
1

我多次遇到错误,但我没有触摸rails生成的文件并ruby -c Gemfile说语法是Ok。在我的情况下,如果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
于 2013-08-22T02:15:17.510 回答