有些东西不断重写我的Gemfile.lock

时间:2017-04-12 21:49:24

标签: ruby bundler

在共享项目上工作时,我经常发现我的Gemfile.lock与存储库不同步,产生如下错误消息:

$ git pull
Updating 1911275..8c5d26f
error: Your local changes to the following files would be overwritten by merge:
    Gemfile.lock
Please commit your changes or stash them before you merge.
Aborting

当我尝试git stash更改时,它无法正常工作:

$ git stash
Saved working directory and index state WIP on development: 1911275 Merge branch 'development' of https://github.com/mygroup/myrepo into development
HEAD is now at 1911275 Merge branch 'development' of https://github.com/mygroup/myrepo into development
$ git status
On branch development
Your branch is behind 'origin/development' by 3 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   Gemfile.lock

no changes added to commit (use "git add" and/or "git commit -a")

如果我stashstatus足够快,我可以看到变化被隐藏起来了:

$ git stash && git status
Saved working directory and index state WIP on development: 1911275 Merge branch 'development' of https://github.com/mygroup/myrepo into development
HEAD is now at 1911275 Merge branch 'development' of https://github.com/mygroup/myrepo into development
On branch development
Your branch is behind 'origin/development' by 3 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

但是另一个status显示Gemfile.lock已经回来了:

$ git status
On branch development
Your branch is behind 'origin/development' by 3 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   Gemfile.lock

no changes added to commit (use "git add" and/or "git commit -a")

不幸的是,同样的伎俩并不适用于git stash && git pull; pull太慢了,锁定文件会在拉动成功之前重新出现。

我认为可能是我的IDE在后台重新捆绑,但无论IDE是否正在运行,都会发生这种情况。我无法找到任何正在运行的bundler进程,gem进程,或任何明显的Ruby进程。

谁或什么正在重新生成我的文件?

1 个答案:

答案 0 :(得分:3)

发现罪魁祸首,感谢this answerthis answer同意):Spring。我的机器上有六个流氓spring进程,其中任何一个或全部都必须重新生成文件。杀死这些流程解决了这个问题,到目前为止,export DISABLE_SPRING=1添加.bash_profile似乎已使其不再发生。

spring stop可能也有效。但我不知道它是否会停止所有Spring进程,或者只是其中之一。)