Heroku: Failed to install gems via Bundler

泪湿孤枕 提交于 2019-12-06 11:30:53

Follow steps -

Step 1: Remove Gemfile.lock from your project by manually or from following command -

rm -rf ~/.bundle/ ~/.gem/ .bundle/ Gemfile.lock

Step 2: Then bundle install

Step 3: git add .

Step 4: git commit -m "commiting Gemfile.lock"

Step 5: git push heroku master -f

First do a "git pull" to merge, and then push again. or try to Execute this: rake assets:precompile git add . git commit -m "Add precompiled assets for Heroku" git push heroku master -f

I'm pretty sure it's that you don't specify the ruby version in your gemfile. I believe Heroku needs this. So it's using ruby 2.0 as the heroku default and then trying to load gems for 1.9.7 as the bundler default.

If this is right, specifying the ruby version number in the gemfile will fix the problem. See http://devcenter.heroku.com/articles/ruby-versions

  1. to make sure you have install posgresSQL on your local by:

    • on MAC:

    brew install postgresql

    • on Ubuntu:

    sudo apt-get install libpq-dev

    • RHEL systems:

    yum install postgresql-devel

  2. Start the postgres on your local

    pg_ctl -D /usr/local/var/postgres start && brew services star postgresql

  3. Let’s make sure Postgres is installed and running

    postgres -V

  4. Login to Postgresql on terminal

    sudo -u postgres psql postgres

(You may need to provide the password 'root' )

  1. Create user Postgres doesn’t actually directly manage users or groups, like most standard permission models do. Instead, it directly manages what it calls roles

    CREATE ROLE testpostgres WITH LOGIN PASSWORD 'root';

  2. Assign createDB permission to our new user

    ALTER ROLE testpostgres CREATEDB;

  3. Set password for new user

    \password testpostgres

  4. Create your DB

    CREATE DATABASE yourDBName;

  5. Used Postico (eggerapps.at/postico/) with UI to manage PostgresDB.

User user setup above to login to your DB via Postico.

  1. After logged in, you may see the image like below

enter image description here

  1. Config your database.yml

    Change all adapter :sqlite3 to adapter :postgresql

    Provide the username and password login to DB by added two fields to your database.yml file like:

    default: &default adapter: postgresql pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> host: localhost username: testpostgres password: root timeout: 5000

Fell free to put your DB name with the field database, like:

production:
  <<: *default
  database: railsapp
  1. Run

    rake db:create

    rake db:migrate

  2. Commit and push code to Heroku again. It should be Ok.

References links :

https://www.codementor.io/devops/tutorial/getting-started-postgresql-server-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!