注意:这与Compass gemfile syntax error on Ubuntu 12.10, Ruby 1.9.3
中提出的问题不同我已经设置了turnkeylinux redmine机器,并将其升级到最新版本的Redmine。在不同的阶段,我需要bundle update
几次,并且它运作良好。
我安装了几个插件和主题,运行了各种rake升级脚本,并使安装工作正常。几个小时后,它给出了Passenger错误,当我尝试使用bundle install安装缺少的gemfile时,我收到了消息
Bundler::GemfileError: Gemfile syntax error:
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/dsl.rb:33:in `rescue in eval_gemfile'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/dsl.rb:29:in `eval_gemfile'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/dsl.rb:9:in `evaluate'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:19:in `build'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/cli.rb:245:in `install'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
/var/lib/gems/1.9.1/gems/bundler- 1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
/var/lib/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
我已经在论坛上通过各种建议,但没有一个有所帮助 - 尽管上面提到的问题有类似的症状。一种解决方案是在顶部而不是在中途添加require 'yaml'
- 也没有快乐。
正在运行ruby -c Gemfile
不会返回语法错误,因此我猜测它并不是一个语法错误 - 但我很高兴出错。重命名Gemfile.lock文件并没有帮助。
任何人都可以光明吗? Gemfile是:
source 'https://rubygems.org'
require 'yaml'
gem "rails", "3.2.21"
gem "jquery-rails", "~> 3.1.1"
gem "coderay", "~> 1.1.0"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", ">= 3.0.4"
gem "request_store", "1.0.5"
gem "mime-types"
gem "rbpdf", "~> 1.18.5"
gem "i18n", "~> 0.6.11"
# Optional gem for LDAP authentication
#group :ldap do
# gem "net-ldap", "~> 0.3.1"
#end
# Optional gem for OpenID authentication
#group :openid do
# gem "ruby-openid", "~> 2.3.0", :require => "openid"
# gem "rack-openid"
#end
platforms :mri, :mingw do
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
group :rmagick do
# RMagick 2 supports ruby 1.9
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# different requirements for the same gem on different platforms
gem "rmagick", (RUBY_VERSION < "1.9" ? "2.13.3" : "~> 2.13.4")
end
# Optional Markdown support, not for JRuby
group :markdown do
# TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped
gem "redcarpet", "~> 2.3.0"
end
end
platforms :jruby do
# jruby-openssl is bundled with JRuby 1.7.0
gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
gem "activerecord-jdbc-adapter", "~> 1.3.2"
end
# Include database gems for the adapters found in the database
# configuration file
require 'erb'
require 'yaml'
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
if File.exist?(database_file)
database_config = YAML::load(ERB.new(IO.read(database_file)).result)
adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
if adapters.any?
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when 'mysql'
gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when /postgresql/
gem "pg", "~> 0.17.1", :platforms => [:mri, :mingw]
gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
when /sqlite3/
gem "sqlite3", :platforms => [:mri, :mingw]
gem "jdbc-sqlite3", "< 3.8", :platforms => :jruby
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
when /sqlserver/
gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw]
gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
else
warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
end
end
else
warn("No adapter found in config/database.yml, please configure it first")
end
else
warn("Please configure your config/database.yml first")
end
group :development do
gem "rdoc", ">= 2.4.2"
gem "yard"
end
group :test do
gem "minitest"
gem "test-unit", "~> 3.0"
gem "shoulda", "~> 3.3.2"
gem "shoulda-matchers", "1.4.1"
gem "mocha", "~> 1.0.0", :require => 'mocha/api'
if RUBY_VERSION >= '1.9.3'
gem "capybara"
gem "selenium-webdriver"
end
end
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile)
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(local_gemfile)
end
# Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
#TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
instance_eval File.read(file), file
end