4

I am trying to deploy my app to Heroku. I removed the 'sqlite3' gem and added the following part to my Gemfile:

gem 'sqlite3', group: :development

group :production do
    gem 'pg'
    gem 'rails_12factor'
end

After that, I ran bundle install to update it. However, when I try to do git add, it said:

error: insufficient permission for adding an object to repository database.git/objects
error: Gemfile.lock: failed to insert into database
error: unable to index file Gemfile.lock
fatal: updating files failed

If I delete the code I added in the Gemfile, everything works just fine! I'm running on OSX 10.11.1, Rails 4.2.4, ruby 2.2.1p85 and git 2.4.9 (Apple Git-60).

mrucci
  • 4,342
  • 3
  • 33
  • 35

2 Answers2

1

The issue is probably because your config/database.yml needs to be configured to use postgresql instead of sqlite.

I highly suggest using postgres for both production AND development by removing the gem 'sqlite3', group: :development from your gemfile and just add gem 'pg' outside of the production group (so it applies to all environments: dev, prod, and test).

Then in your database.yml, in the default: &default section, change adapter to:

  adapter: postgresql

Or if you want to continue using sqlite in dev, just change the production: section in your database.yml to the following:

production:
  adapter: postgresql
  encoding: unicode
  pool: 5

You might need to change the database: value to something like:

  database: your_app_name_production

where "your_app_name" is the name of your app.

NOTE: Be sure to keep the spacing exact as YAML files are whitespace sensitive.

Hope that helps.

Ira Herman
  • 2,796
  • 1
  • 23
  • 22
1

Or it could be something wrong with your Gemfile.lock.

You should be able to safely delete that file (make a backup copy first, just in case). Use git rm Gemfile.lock. Gemfile.lock just tracks all the versions of all the gems installed in your project based on the latest version at the point in time you first bundle installed them.

Then when you run bundle install it will automatically generate a new one.

Then do a git add -A again (better to use that than git add *).

Ira Herman
  • 2,796
  • 1
  • 23
  • 22