2014-04-08 22 views
0

我收到以下錯誤,當我運行heroku run rake db:createHeroku的運行耙分貝:創建失敗,未能找到寶石「皮克......,但數據庫mysql2(不是PostgreSQL的)

Running `rake db:create` attached to terminal... up, run.6027 
Could not find gem 'pg (>= 0.11.0) ruby' in the gems available on this machine. 
Run `bundle install` to install missing gems. 

在配置/database.yml我使用的是默認的數據庫mysql2:

production: 
    adapter: mysql2 
    database: redmine 
    host: localhost 
    ... 
development: 
    adapter: mysql2 
    ... 
test: 
    adapter: mysql2 
    ... 

所以我想「皮克(> = 0.11.0)紅寶石」並不需要安裝。我錯了嗎?

我正在使用Windows XP。這是我第一次使用Ruby。


更新1

我忘了說bundle install正確完成沒有錯誤。

在另一方面,Gemfile中具有下面的代碼:

adapters.each do |adapter| 
    case adapter 
    when 'mysql2' 
    gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw] 
    gem "activerecord-jdbcmysql-adapter", :platforms => :jruby 
    ... 
    when /postgresql/ 
    gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw] 
    gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby 
    ... 

如此反覆,我想執行的命令heroku run rake db:create當它不應該在when /postgresql/進入。我對嗎?

+0

您是否向您的Heroku應用程序添加了MySQL數據庫? –

+0

@NickVeys,我執行了gem install'mysql2 -v'0.3.11''並且它正確地完成了。我有mysql-5.6.10的二進制文件,但我沒有運行數據庫。無論如何,錯誤似乎是因爲它無法安裝_pg(> = 0.11.0)ruby_ – chelder

+0

您正在使用Heroku,它是一個應用程序平臺。它沒有MySQL數據庫,除非你添加一個。你在學習一個教程嗎? Heroku通常使用Postgres。 –

回答

1

查看上面的討論...這是一個Heroku應用程序,它需要配置一個數據庫,或者它將嘗試強制Postgres作爲依賴來幫助你。

1

在運行創建數據庫的rake任務之前,您需要執行軟件包安裝並完成所有gem依賴項。這是必需的,即使你使用的是mysql而不是postgres,因爲在Gemfile中指定了'pg gem',並且必須通過運行軟件包安裝命令來確保Gemfile中的所有gem依賴項都可用於應用程序。

在你的情況下,你使用的是mysql,你不需要'pg gem',並且可以在Gemfile中刪除或註釋它。

+0

哦。我忘記說**捆綁安裝**正確完成沒有錯誤。它認爲不應該有必要刪除Gemfile中的那一行,因爲我將在** update 1 **中進行解釋。 – chelder

相關問題