heroku 运行 rake db:migrate 失败,gem pg 未找到; gem 安装 pg 重复
heroku run rake db:migrate fails, gem pg not found; gem install pg repeats
我是 rails 的初学者,试图将我的小应用程序推送到 heroku。在本地,我已将我的数据库从 mysql2
移动到 postgresql
,但无法 运行 我在 heroku 上的应用程序。本地一切都如预期的那样 运行ning。
production:
adapter: postgresql
database: database_production
pool: 5
timeout: 5000
运行 heroku run rake db:create
或 heroku run rake db:migrate
returns:
$ heroku run rake --trace db:create
Running `rake --trace db:create` attached to terminal... up, run.5709
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
Specified 'postgresql' for database adapter, but the gem is not loaded.
Add `gem 'pg'` to your Gemfile
(and ensure its version is at the minimum required by ActiveRecord).
我可以heroku run gem install pg
多次
$ heroku run gem install pg
Running `gem install pg` attached to terminal... up, run.9322
Fetching: pg-0.18.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed pg-0.18.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.1
Installing ri documentation for pg-0.18.1
Done installing documentation for pg after 3 seconds
1 gem installed
$ heroku run gem install pg
Running `gem install pg` attached to terminal... up, run.7925
Fetching: pg-0.18.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed pg-0.18.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.1
Installing ri documentation for pg-0.18.1
Done installing documentation for pg after 4 seconds
1 gem installed
...
..etc
我也注意到了一些奇怪的事情,但不确定是否相关。 运行 heroku run bundle install --no-deployment
显示正在安装 mysql2
,但我已经将其从 gemfile 中删除。
Running `bundle install --no-deployment` attached to terminal... up, run.1928
Fetching gem metadata from https://rubygems.org/.........
Installing i18n 0.7.0
Installing rake 10.4.2
Installing thread_safe 0.3.4
Installing minitest 5.5.1
Installing erubis 2.7.0
Installing builder 3.2.2
Installing mini_portile 0.6.2
Installing rack 1.6.0
Installing mime-types 2.4.3
Installing arel 6.0.0
Installing execjs 2.3.0
Installing sass 3.4.12
Installing json 1.8.2
Installing cancancan 1.10.1
Installing chunky_png 1.3.4
Installing coffee-script-source 1.9.1
Installing thor 0.19.1
Installing multi_json 1.10.1
Installing rb-fsevent 0.9.4
Installing hike 1.2.3
Installing tilt 1.4.1
Installing bcrypt 3.1.10
Using bundler 1.7.12
Installing tzinfo 1.2.2
Installing mysql2 0.3.18
Installing rack-test 0.6.3
Installing mail 2.6.3
Installing compass-import-once 1.0.5
Installing autoprefixer-rails 5.1.7
Installing rdoc 4.2.0
Installing uglifier 2.7.0
Installing coffee-script 2.3.0
Installing compass-core 1.0.3
Installing sprockets 2.12.3
Installing activesupport 4.2.0
Installing bootstrap-sass 3.3.3
Installing sdoc 0.4.1
Installing rails-deprecated_sanitizer 1.0.3
Installing globalid 0.3.3
Installing activemodel 4.2.0
Installing jbuilder 2.2.7
Installing activejob 4.2.0
Installing activerecord 4.2.0
Installing ffi 1.9.6
Installing rb-inotify 0.9.5
Installing compass 1.0.3
Installing compass-normalize 1.5
Installing nokogiri 1.6.6.2
Installing loofah 2.0.1
Installing rails-dom-testing 1.0.5
Installing rails-html-sanitizer 1.0.1
Installing actionview 4.2.0
Installing actionpack 4.2.0
Installing sprockets-rails 2.2.4
Installing railties 4.2.0
Installing coffee-rails 4.1.0
Installing sass-rails 5.0.1
Installing turbolinks 2.5.3
Installing jquery-rails 4.0.3
Installing compass-rails 2.0.4
Installing actionmailer 4.2.0
Installing rails 4.2.0
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
您必须将 pg
添加到 Gemfile
和 运行 bundle install
而不是尝试在 heroku 上手动安装 gem。将此添加到您的应用程序的 Gemfile
:
gem 'pg'
大家好,我发现了我的错误。我的 gitbucket 存储库没有用最新的 gemfile.lock 正确更新,所以当我 git push heroku master
它使用了错误的文件来安装 - 因此它没有安装 gem 'pg'
应该。下面是更新回购后,
remote: Installing pg 0.18.1
结果:
$ git push heroku master
Counting objects: 227, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (188/188), done.
Writing objects: 100% (196/196), 86.44 KiB | 0 bytes/s, done.
Total 196 (delta 116), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.1.5
remote: -----> Installing dependencies using 1.7.12
remote: Ruby version change detected. Clearing bundler cache.
remote: Old: ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux]
remote: New: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Fetching gem metadata from https://rubygems.org/.........
remote: Installing rake 10.4.2
remote: Installing i18n 0.7.0
remote: Installing minitest 5.5.1
remote: Installing builder 3.2.2
remote: Installing erubis 2.7.0
remote: Installing mini_portile 0.6.2
remote: Installing rack 1.6.0
remote: Installing json 1.8.2
remote: Installing mime-types 2.4.3
remote: Installing arel 6.0.0
remote: Installing execjs 2.3.0
remote: Installing sass 3.4.12
remote: Installing cancancan 1.10.1
remote: Installing chunky_png 1.3.4
remote: Installing thread_safe 0.3.4
remote: Installing coffee-script-source 1.9.1
remote: Installing bcrypt 3.1.10
remote: Installing multi_json 1.10.1
remote: Installing thor 0.19.1
remote: Installing rb-fsevent 0.9.4
remote: Installing tilt 1.4.1
remote: Installing hike 1.2.3
remote: Installing jquery 0.0.1
remote: Using bundler 1.7.12
remote: Installing rails_serve_static_assets 0.0.4
remote: Installing rails_stdout_logging 0.0.3
remote: Installing pg 0.18.1
remote: Installing rack-test 0.6.3
remote: Installing nokogiri 1.6.6.2
remote: Installing rdoc 4.2.0
remote: Installing mail 2.6.3
remote: Installing autoprefixer-rails 5.1.7
remote: Installing puma 2.11.1
remote: Installing uglifier 2.7.0
remote: Installing compass-import-once 1.0.5
remote: Installing coffee-script 2.3.0
remote: Installing tzinfo 1.2.2
remote: Installing sprockets 2.12.3
remote: Installing compass-core 1.0.3
remote: Installing rails_12factor 0.0.2
remote: Installing loofah 2.0.1
remote: Installing sdoc 0.4.1
remote: Installing bootstrap-sass 3.3.3
remote: Installing activesupport 4.2.0
remote: Installing rails-html-sanitizer 1.0.1
remote: Installing rails-deprecated_sanitizer 1.0.3
remote: Installing globalid 0.3.3
remote: Installing activemodel 4.2.0
remote: Installing rails-dom-testing 1.0.5
remote: Installing jbuilder 2.2.8
remote: Installing activejob 4.2.0
remote: Installing activerecord 4.2.0
remote: Installing actionview 4.2.0
remote: Installing actionpack 4.2.0
remote: Installing railties 4.2.0
remote: Installing actionmailer 4.2.0
remote: Installing sprockets-rails 2.2.4
remote: Installing coffee-rails 4.1.0
remote: Installing sass-rails 5.0.1
remote: Installing jquery-rails 4.0.3
remote: Installing rails 4.2.0
remote: Installing turbolinks 2.5.3
remote: Installing ffi 1.9.6
remote: Installing rb-inotify 0.9.5
remote: Installing compass 1.0.3
remote: Installing compass-normalize 1.5
remote: Installing compass-rails 2.0.4
remote: Your bundle is complete!
remote: Gems in the groups development and test were not installed.
remote: It was installed into ./vendor/bundle
remote: Post-install message from rdoc:
remote: Depending on your version of ruby, you may need to install ruby rdoc/ri data:
remote: <= 1.8.6 : unsupported
remote: = 1.8.7 : gem install rdoc-data; rdoc-data --install
remote: = 1.9.1 : gem install rdoc-data; rdoc-data --install
remote: >= 1.9.2 : nothing to do! Yay!
remote: Post-install message from compass:
remote: Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
remote: Bundle completed (53.27s)
remote: Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: I, [2015-02-22T12:12:37.186296 #3823] INFO -- : Writing /tmp/build_39c4ef560255ffc2b75041a3c43b0fe0/public/assets/application-3fbdcccb5f04a215dfa1c3b6cc3d3df5.js
remote: I, [2015-02-22T12:12:47.594119 #3823] INFO -- : Writing /tmp/build_39c4ef560255ffc2b75041a3c43b0fe0/public/assets/application-1aa5e71d1c1c4ad6b0fd474b04a30100.css
remote: Asset precompilation completed (18.56s)
remote: Cleaning assets
remote: Running: rake assets:clean
remote:
remote: ###### WARNING:
remote: No Procfile detected, using the default web server (webrick)
remote: https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for Ruby -> console, rake, web, worker
remote:
remote: -----> Compressing... done, 37.6MB
remote: -----> Launching... done, v7
remote: https://<app-name>.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy.... done.
感谢大家的帮助,我犯了一个愚蠢的错误。
我是 rails 的初学者,试图将我的小应用程序推送到 heroku。在本地,我已将我的数据库从 mysql2
移动到 postgresql
,但无法 运行 我在 heroku 上的应用程序。本地一切都如预期的那样 运行ning。
production:
adapter: postgresql
database: database_production
pool: 5
timeout: 5000
运行 heroku run rake db:create
或 heroku run rake db:migrate
returns:
$ heroku run rake --trace db:create
Running `rake --trace db:create` attached to terminal... up, run.5709
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
Specified 'postgresql' for database adapter, but the gem is not loaded.
Add `gem 'pg'` to your Gemfile
(and ensure its version is at the minimum required by ActiveRecord).
我可以heroku run gem install pg
多次
$ heroku run gem install pg
Running `gem install pg` attached to terminal... up, run.9322
Fetching: pg-0.18.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed pg-0.18.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.1
Installing ri documentation for pg-0.18.1
Done installing documentation for pg after 3 seconds
1 gem installed
$ heroku run gem install pg
Running `gem install pg` attached to terminal... up, run.7925
Fetching: pg-0.18.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed pg-0.18.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.1
Installing ri documentation for pg-0.18.1
Done installing documentation for pg after 4 seconds
1 gem installed
...
..etc
我也注意到了一些奇怪的事情,但不确定是否相关。 运行 heroku run bundle install --no-deployment
显示正在安装 mysql2
,但我已经将其从 gemfile 中删除。
Running `bundle install --no-deployment` attached to terminal... up, run.1928
Fetching gem metadata from https://rubygems.org/.........
Installing i18n 0.7.0
Installing rake 10.4.2
Installing thread_safe 0.3.4
Installing minitest 5.5.1
Installing erubis 2.7.0
Installing builder 3.2.2
Installing mini_portile 0.6.2
Installing rack 1.6.0
Installing mime-types 2.4.3
Installing arel 6.0.0
Installing execjs 2.3.0
Installing sass 3.4.12
Installing json 1.8.2
Installing cancancan 1.10.1
Installing chunky_png 1.3.4
Installing coffee-script-source 1.9.1
Installing thor 0.19.1
Installing multi_json 1.10.1
Installing rb-fsevent 0.9.4
Installing hike 1.2.3
Installing tilt 1.4.1
Installing bcrypt 3.1.10
Using bundler 1.7.12
Installing tzinfo 1.2.2
Installing mysql2 0.3.18
Installing rack-test 0.6.3
Installing mail 2.6.3
Installing compass-import-once 1.0.5
Installing autoprefixer-rails 5.1.7
Installing rdoc 4.2.0
Installing uglifier 2.7.0
Installing coffee-script 2.3.0
Installing compass-core 1.0.3
Installing sprockets 2.12.3
Installing activesupport 4.2.0
Installing bootstrap-sass 3.3.3
Installing sdoc 0.4.1
Installing rails-deprecated_sanitizer 1.0.3
Installing globalid 0.3.3
Installing activemodel 4.2.0
Installing jbuilder 2.2.7
Installing activejob 4.2.0
Installing activerecord 4.2.0
Installing ffi 1.9.6
Installing rb-inotify 0.9.5
Installing compass 1.0.3
Installing compass-normalize 1.5
Installing nokogiri 1.6.6.2
Installing loofah 2.0.1
Installing rails-dom-testing 1.0.5
Installing rails-html-sanitizer 1.0.1
Installing actionview 4.2.0
Installing actionpack 4.2.0
Installing sprockets-rails 2.2.4
Installing railties 4.2.0
Installing coffee-rails 4.1.0
Installing sass-rails 5.0.1
Installing turbolinks 2.5.3
Installing jquery-rails 4.0.3
Installing compass-rails 2.0.4
Installing actionmailer 4.2.0
Installing rails 4.2.0
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
您必须将 pg
添加到 Gemfile
和 运行 bundle install
而不是尝试在 heroku 上手动安装 gem。将此添加到您的应用程序的 Gemfile
:
gem 'pg'
大家好,我发现了我的错误。我的 gitbucket 存储库没有用最新的 gemfile.lock 正确更新,所以当我 git push heroku master
它使用了错误的文件来安装 - 因此它没有安装 gem 'pg'
应该。下面是更新回购后,
remote: Installing pg 0.18.1
结果:
$ git push heroku master
Counting objects: 227, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (188/188), done.
Writing objects: 100% (196/196), 86.44 KiB | 0 bytes/s, done.
Total 196 (delta 116), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.1.5
remote: -----> Installing dependencies using 1.7.12
remote: Ruby version change detected. Clearing bundler cache.
remote: Old: ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux]
remote: New: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Fetching gem metadata from https://rubygems.org/.........
remote: Installing rake 10.4.2
remote: Installing i18n 0.7.0
remote: Installing minitest 5.5.1
remote: Installing builder 3.2.2
remote: Installing erubis 2.7.0
remote: Installing mini_portile 0.6.2
remote: Installing rack 1.6.0
remote: Installing json 1.8.2
remote: Installing mime-types 2.4.3
remote: Installing arel 6.0.0
remote: Installing execjs 2.3.0
remote: Installing sass 3.4.12
remote: Installing cancancan 1.10.1
remote: Installing chunky_png 1.3.4
remote: Installing thread_safe 0.3.4
remote: Installing coffee-script-source 1.9.1
remote: Installing bcrypt 3.1.10
remote: Installing multi_json 1.10.1
remote: Installing thor 0.19.1
remote: Installing rb-fsevent 0.9.4
remote: Installing tilt 1.4.1
remote: Installing hike 1.2.3
remote: Installing jquery 0.0.1
remote: Using bundler 1.7.12
remote: Installing rails_serve_static_assets 0.0.4
remote: Installing rails_stdout_logging 0.0.3
remote: Installing pg 0.18.1
remote: Installing rack-test 0.6.3
remote: Installing nokogiri 1.6.6.2
remote: Installing rdoc 4.2.0
remote: Installing mail 2.6.3
remote: Installing autoprefixer-rails 5.1.7
remote: Installing puma 2.11.1
remote: Installing uglifier 2.7.0
remote: Installing compass-import-once 1.0.5
remote: Installing coffee-script 2.3.0
remote: Installing tzinfo 1.2.2
remote: Installing sprockets 2.12.3
remote: Installing compass-core 1.0.3
remote: Installing rails_12factor 0.0.2
remote: Installing loofah 2.0.1
remote: Installing sdoc 0.4.1
remote: Installing bootstrap-sass 3.3.3
remote: Installing activesupport 4.2.0
remote: Installing rails-html-sanitizer 1.0.1
remote: Installing rails-deprecated_sanitizer 1.0.3
remote: Installing globalid 0.3.3
remote: Installing activemodel 4.2.0
remote: Installing rails-dom-testing 1.0.5
remote: Installing jbuilder 2.2.8
remote: Installing activejob 4.2.0
remote: Installing activerecord 4.2.0
remote: Installing actionview 4.2.0
remote: Installing actionpack 4.2.0
remote: Installing railties 4.2.0
remote: Installing actionmailer 4.2.0
remote: Installing sprockets-rails 2.2.4
remote: Installing coffee-rails 4.1.0
remote: Installing sass-rails 5.0.1
remote: Installing jquery-rails 4.0.3
remote: Installing rails 4.2.0
remote: Installing turbolinks 2.5.3
remote: Installing ffi 1.9.6
remote: Installing rb-inotify 0.9.5
remote: Installing compass 1.0.3
remote: Installing compass-normalize 1.5
remote: Installing compass-rails 2.0.4
remote: Your bundle is complete!
remote: Gems in the groups development and test were not installed.
remote: It was installed into ./vendor/bundle
remote: Post-install message from rdoc:
remote: Depending on your version of ruby, you may need to install ruby rdoc/ri data:
remote: <= 1.8.6 : unsupported
remote: = 1.8.7 : gem install rdoc-data; rdoc-data --install
remote: = 1.9.1 : gem install rdoc-data; rdoc-data --install
remote: >= 1.9.2 : nothing to do! Yay!
remote: Post-install message from compass:
remote: Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
remote: Bundle completed (53.27s)
remote: Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: I, [2015-02-22T12:12:37.186296 #3823] INFO -- : Writing /tmp/build_39c4ef560255ffc2b75041a3c43b0fe0/public/assets/application-3fbdcccb5f04a215dfa1c3b6cc3d3df5.js
remote: I, [2015-02-22T12:12:47.594119 #3823] INFO -- : Writing /tmp/build_39c4ef560255ffc2b75041a3c43b0fe0/public/assets/application-1aa5e71d1c1c4ad6b0fd474b04a30100.css
remote: Asset precompilation completed (18.56s)
remote: Cleaning assets
remote: Running: rake assets:clean
remote:
remote: ###### WARNING:
remote: No Procfile detected, using the default web server (webrick)
remote: https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for Ruby -> console, rake, web, worker
remote:
remote: -----> Compressing... done, 37.6MB
remote: -----> Launching... done, v7
remote: https://<app-name>.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy.... done.
感谢大家的帮助,我犯了一个愚蠢的错误。