rake db:迁移rake中止了!无法从现有的gemspec中确定名称

时间:2013-05-05 15:38:28

标签: ruby ruby-on-rails-3 rake rails-migrations rakefile

我正在尝试使用db:migrate。我克隆了一个存储库并尝试使用db:migrate,但是出现了这个错误:

rake aborted!
Unable to determine name from existing gemspec. Use :name => 'gemname' in #inst
ll_tasks to manually set it. C:/Users/Dila/Documents/emo_project/Rakefile:6:in `<top (required)>'

在我的Rakefile第6行中,我有这个:

require "bundler/gem_tasks"

这是我得到的,当我追踪它时:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:30:i
n `initialize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:14:i
n `new'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:14:i
n `install_tasks'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/gem_tasks.rb:2:in
`<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/depen
dencies.rb:251:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/depen
dencies.rb:251:in `block in require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/depen
dencies.rb:236:in `load_dependency'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_support/depen
dencies.rb:251:in `require'
C:/Users/Dila/Documents/emo_project/Rakefile:6:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in `l
oad'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in `l
oad_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:589:in `
raw_load_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:89:in `b
lock in load_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `
standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:88:in `l
oad_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:72:in `b
lock in run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `
standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `r
un'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>
'
C:/Ruby193/bin/rake:23:in `load'
C:/Ruby193/bin/rake:23:in `<main>'

我不知道出了什么问题,因为昨天我在办公室工作,一切都很好。我只是想尝试在我的笔记本电脑中克隆存储库,但它不起作用。

我的gemfile:

source 'https://rubygems.org'

if RUBY_VERSION =~ /1.9/
  Encoding.default_external = Encoding::UTF_8
  Encoding.default_internal = Encoding::UTF_8
end

group :production do
  gem 'pg', '0.12.2'
end

gem 'magic_encoding'

gem 'rails', '3.2.2'

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

gem 'sqlite3'

gem 'activeadmin'

gem "bcrypt-ruby", :require => "bcrypt"

# to copy to clipboard
gem 'zeroclipboard-rails'


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

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

  gem 'uglifier', '>= 1.0.4'
  gem 'sass-rails', '~> 3.2'
  gem 'bootstrap-sass', '~> 2.3.1.0'
  gem 'closure-compiler'

end

gem 'jquery-rails'

1 个答案:

答案 0 :(得分:0)

我在你的gemfile中看到你将postgresql设置为你的生产数据库,但你也设置了sqlite来运行生产,测试和开发。

group :production do
  gem 'pg', '0.12.2'
end

# Skip some lines to here

gem 'sqlite3'

我会确保您的数据库在测试,开发和生产服务器上是统一的。我会删除sqlite3,只需要

group :production do
  gem 'pg', '0.12.2'
end

替换为

gem 'pg', '0.12.2'

这样,postgresql将在所有平台上运行。或者如果你的database.yml连接到sqlite,那么去掉postgresql并将sqlite gem保存在你的gemfile中。