簡體   English   中英

可以將Gemfile和Gemfile.lock添加到git

[英]Can add Gemfile and Gemfile.lock to git

我正在嘗試將我的應用程序部署到Heroku。 我刪除了'sqlite3'gem並將以下部分添加到我的Gemfile中:

gem 'sqlite3', group: :development

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

之后,我運行了bundle install來更新它。 但是,當我嘗試做git add ,它說:

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

如果我刪除了我在Gemfile中添加的代碼,一切正常! 我正在運行OSX 10.11.1,Rails 4.2.4,ruby 2.2.1p85和git 2.4.9(Apple Git-60)。

問題可能是因為您的config / database.yml需要配置為使用postgresql而不是sqlite。

我通過移除強烈建議使用的是Postgres為生產 發展gem 'sqlite3', group: :development從您的Gemfile,只是添加gem 'pg'制作組之外(所以它適用於所有環境:開發,prod和測試)。

然后在您的database.yml中,在default: &default部分中,將適配器更改為:

  adapter: postgresql

或者,如果要繼續在dev中使用sqlite,只需將database.yml中的production:部分更改為以下內容:

production:
  adapter: postgresql
  encoding: unicode
  pool: 5

您可能需要將database: value更改為:

  database: your_app_name_production

其中“your_app_name”是您的應用程序的名稱。

注意:請務必保持間距精確,因為YAML文件對空白敏感。

希望有所幫助。

或者你的Gemfile.lock可能有問題。

您應該能夠安全地刪除該文件(首先制作備份副本,以防萬一)。 使用git rm Gemfile.lock Gemfile.lock只是在你第一次捆綁安裝它們的時候根據最新版本跟蹤項目中安裝的所有gem的所有版本。

然后,當您運行bundle install ,它將自動生成一個新的。

然后再做一個git add -A (最好使用git add * )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM