在 heroku 上部署 diaspora 时出错无法通过 Bundler 安装 gems

error while deploying diaspora on heroku Failed to install gems via Bundler

我正在尝试在 heroku 上部署 diaspora 但在部署时出现此错误我使用 rails 4.1.8 和 ruby 2.0.0 在 ubuntu 14.04 我试过 bundle update 但它不起作用..任何解决方案..??

> ahmed@ahmed-desktop:~/diaspora$ git push -u heroku heroku:master
> Counting objects: 132081, done.
> Delta compression using up to 2 threads.
> Compressing objects: 100% (29619/29619), done.
> Writing objects: 100% (132081/132081), 91.87 MiB | 163.00 KiB/s, done.
> Total 132081 (delta 101146), reused 132070 (delta 101138)
> remote: Compressing source files... done.
> remote: Building source:
> remote:
> remote: -----> Deleting 6 files matching .slugignore patterns.
> remote: -----> Ruby app detected
> remote: -----> Compiling Ruby/Rails
> remote: -----> Using Ruby version: ruby-2.0.0
> remote: -----> Installing dependencies using 1.7.12
> remote:        Running: bundle install --without development:test --path
> vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
> remote:        You are trying to install in deployment mode after changing
> remote:        your Gemfile. Run `bundle install` elsewhere and add the
> remote:        updated Gemfile.lock to version control.
> remote:        You have deleted from the Gemfile:
> remote:        * mysql2 (= 0.3.16)
> remote:        Bundler Output: You are trying to install in deployment
> mode after changing
> remote:        your Gemfile. Run `bundle install` elsewhere and add the
> remote:        updated Gemfile.lock to version control.
> remote:
> remote:        You have deleted from the Gemfile:
> remote:        * mysql2 (= 0.3.16)
> remote:  !
> remote:  !     Failed to install gems via Bundler.
> remote:  !
> remote:
> remote:  !     Push rejected, failed to compile Ruby app
> remote:
> remote: Verifying deploy...
> remote:
> remote: !    Push rejected to reddodo.
> remote:
> To https://git.heroku.com/reddodo.git
>  ! [remote rejected] heroku -> master (pre-receive hook declined)
> error: failed to push some refs to 'https://git.heroku.com/reddodo.git'

我认为问题在于 heroku 不支持开箱即用的 mysql。您将需要切换到 Postgres 或使用插件,例如 ClearDB.

更新: 再想想可能是this

The error message you're getting regarding Gemfile.lock may be because your Gemfile and Gemfile.lock don't agree with each other. It sounds like you've changed something in your Gemfile since you last ran bundle install (or update). When you bundle install, it updates your Gemfile.lock with any changes you've made to Gemfile.

Make sure you run bundle install locally, and check-in to source control your newly updated Gemfile.lock after that. Then try deploying.

Edit: As recognised in the comments, a conditional in the Gemfile resulted in a valid Gemfile.lock on one platform, invalid on another. Providing a :platform flag for these platform-dependent gems in the Gemfile should solve the asymmetry.

~ Edd Morgan

您跳过了部分 installation instructions,即:

We need to switch the Gemfile.lock to PostgreSQL. Edit Gemfile and change ENV['DB'] ||= 'mysql' to ENV['DB'] ||= 'postgres'. Then run:

bundle --without development test heroku production assets
git add Gemfile Gemfile.lock
git commit -m "switch Gemfile.lock to pg exclusivly"