Gemfile.lock always has changes not staged for commit

后端 未结 2 945
后悔当初
后悔当初 2021-02-14 19:17

I am running into this problem on a rails app I am working on. I was working on a feature branch and wanted to rebase from the most recent master. I ran the following commands:<

相关标签:
2条回答
  • 2021-02-14 19:25

    There must be some process running in the background or some side-effect of executing the git commands in your shell that is modifying the Gemfile.lock.

    I am not familiar with rvm's magic (although that sounds plausible); here are some other things to check:

    • In recent versions of Rails there is a "spring" background process that runs. Try running spring stop (or bin/spring stop or bundle exec spring stop) to gracefully terminate that process.
    • Likewise if you have any other Rails-related processes like rails server, guard, zeus, sidekiq, etc. running, try shutting those down.
    • You might be running a git pre-commit hook. Check the .git/hooks directory.
    • git might be an alias in your shell for another command. Run alias to see a list of shell aliases.
    • Your shell prompt might be executing code to do things like show the current git status and branch name in the prompt. This code would be executed after every shell command to redraw the prompt, and might have side-effects. Check your .bashrc or .bash_profile.
    0 讨论(0)
  • 2021-02-14 19:39

    There are times that running a rails command or other bundle exec command will silently update your Gemfile.lock. I am guessing you are doing that sometime in between your git commands. Or you have something weird installed that does that invisibly.

    (Could rvm do this invisibly? I don't know. I think rvm does all kinds of odd stuff and don't use it.).

    At any rate, the fact that this is happening is probably evidence of something else going on that isn't what you want -- are you sure the Gemfile and Gemfile.lock you are trying to commit together are actually compatible? Normally any time a Gemfile changes at all, it is wise to run bundle install to get a new Gemfile.lock. If you are trying to commit a Gemfile.lock which actually isn't compatible with the Gemfile... I am not sure why you would want to do that anyway, normally I want the Gemfile and Gemfile.lock in any given commit to be compatible.

    To get a clue as to why something (mysterious) may be changing your Gemfile.lock, do a git diff on the Gemfile.lock to see how it's changed?

    0 讨论(0)
提交回复
热议问题