DEV Community

Robert Rees
Robert Rees

Posted on

5 2

Resolving Git conflicts in Pipenv Lockfiles

I'm writing this principally for me to find via Google the next time this happens. Which is to say that the problem occurs relatively frequently but not enough that I can remember how to resolve but instead vaguely remember that it was painful.

tldr: get the file parseable and then run pipenv lock

The essential cause of merge conflicts in the pipenv Lockfile is the package SHA that changes whenever you change a dependency. If dependencies are changing in different branches then you are almost guaranteed to get merge conflicts.

The important thing is that while the git merge markers are in the file pipenv can't run because it needs to parse the lockfile before it does anything else.

It doesn't really matter which merge you choose so assuming your pull is on a tested branch you should be able to use git checkout --theirs Pipfile.lock.

Once the file is parseable you can just run pipenv lock to regenerate the lockfile with the correct combined dependencies.

Assuming there are no version conflicts as a result of the combined dependency requirements you should be done and can commit the newly generated file as the result of the merge.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (2)

Collapse
 
dawnwages profile image
Dawn Wages

SAME! I had to look this up last week. Do you mind if I mention you in my blog?

Collapse
 
rrees profile image
Robert Rees

Sorry, I missed the notification. No problem.

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay