【问题标题】:Something keeps rewriting my Gemfile.lock [duplicate]有些东西不断重写我的 Gemfile.lock [重复]
【发布时间】:2017-04-12 21:49:23
【问题描述】:

在处理共享项目时,我经常发现我的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 &amp;&amp; git pullpull太慢了,拉取成功之前锁文件重新出现。

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

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

【问题讨论】:

  • 你能忽略你的锁文件吗?我知道这不能回答问题,但可以解决问题
  • 你使用的是什么操作系统?
  • 告诉我们锁定文件的变化。这就是线索。
  • @BradWerth macOS (El Capitan)。
  • @engineersmnky 为了重现性,我们希望应用程序 Gemfile.lock 在版本控制中。 (参见 Cargo.lock 周围的this discussion,它在 Rust 世界中扮演着类似的角色。)

标签: ruby bundler


【解决方案1】:

找到罪魁祸首,感谢this answerthis answer 同意):Spring。我的机器上有六个流氓spring 进程,它们中的任何一个或全部肯定在重新生成文件。杀死这些进程解决了这个问题,到目前为止,将export DISABLE_SPRING=1 添加到我的.bash_profile 似乎可以防止它再次发生。

spring stop 可能也有效。不过,我不知道它是停止所有 Spring 进程还是仅停止其中一个。)

【讨论】:

  • 谢谢! spring stop 帮了我大忙。
  • 非常感谢,伙计。遇到了同样的问题。你是救生员
  • killall -9 ruby ftw,厌倦了春天和它的干扰。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-09
  • 2023-02-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多