2013-03-12 59 views
2

我得到以下錯誤:Gemfile語法錯誤。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' 

回答

10

你錯過了enddogroup :development。在gem 'sqlite3'後面添加一條end聲明。

你可以運行ruby -c Gemfile來檢查語法(它是普通的Ruby代碼),它會讓你知道錯誤在哪裏。

+1

語法檢查對我很重要。謝謝你的回答。 – 2013-06-12 01:07:57

1

看起來你缺少development組後結束。

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