Skip to content

git - Should Pipfile.lock be committed to version control? #598

Closed

Description

@LeCoupa

When two developers are working on a projet with different operating systems, the Pipfile.lock is different (especially the part inside host-environment-markers).

For Composer, most people recommend to commit composer.lock. Do we have to do the same for Pipenv?

Activity

  1. kennethreitz commented on Sep 19, 2017

    @kennethreitz
    Contributor

    i recommend it.

  2. kennethreitz commented on Sep 19, 2017

    @kennethreitz
    Contributor

    Especially for applications. For libraries, less so.

  3. LeCoupa commented on Sep 19, 2017

    @LeCoupa
    Author

    Thanks a lot @kennethreitz

  4. salty-horse commented on Oct 1, 2017

    @salty-horse
    Contributor

    Should this recommendation be documented? Perhaps in a section similar to Composer's.

  5. dougireton commented on Jan 30, 2018

    @dougireton

    Are their negative consequences to using a Pipfile.lock across OS types? In other words, if I generate my Pipfile.lock on MacOS, then deploy to Linux will Pipenv "do bad things"?

  6. uranusjr commented on Jan 31, 2018

    @uranusjr
    Member

    @dougireton This depends on your dependencies. Using a lockfile from a different OS is fine if all your packages are modern and well-behaved (either platform-agnostic or have good cross-platform support). Otherwise Pipenv can do things wrong, like installing dependencies that don’t work, or not installing all needed dependencies.

  7. kennethreitz commented on Feb 17, 2018

    @kennethreitz
    Contributor

    Generally, yes you should commit it to version control.

  8. behrangsa commented on Feb 28, 2018

    @behrangsa

    How come pipenv's own Pipefile.lock is not added to git then?

  9. kennethreitz commented on Feb 28, 2018

    @kennethreitz
    Contributor

    because we are special snowflakes.

  10. anentropic commented on Mar 7, 2018

    @anentropic

    I'm happy to take this advice as correct but I would like to understand why it is given.

    the docs say:

    Generally, keep both Pipfile and Pipfile.lock in version control.

    but I couldn't find any more reasoning in the docs, can you point me to it?

    Pipfile.lock is auto-generated and contents will differ depending on platform. If I'm developing on macOS and deploying to Debian ...already it sounds to me like I don't want the lock file in version control.

    Then the comment above says:

    Using a lockfile from a different OS is fine if all your packages are modern and well-behaved (either platform-agnostic or have good cross-platform support). Otherwise Pipenv can do things wrong, like installing dependencies that don’t work, or not installing all needed dependencies.

    Again it sounds like I would not want the lock file in version control.

    Here is someone asking similar question #954

    Reading through the responses on that issue I have a clearer idea of why I would want it. I think the docs need more elaboration.

    The related question is how explicitly should versions be specified in the Pipfile?

    If I do pipenv install <package> during development to get the latest version, it will go in the Pipfile with no version specifier. If everyone else gets my Pipfile.lock from vc and does pipenv install --ignore-pipfile they get pinned to the versions I installed, and no need to be more specific in the Pipfile. All good. If they don't do --ignore-pipfile then the lock file may change if a package updated and they have to decide whether to commit the changes. Ok. At any time devs can pipenv update <package> and the Pipfile won't change but the lock file will, and we would commit that. Ok. Is this the intended workflow?

    But if the other dev is on a different platform the lock file contents will change(?) but it's not necessarily due to different package versions and we wouldn't want to commit it. Hmm.

    And I would only add version specifier to Pipfile if for example I knew at dev time that I needed to install a non-latest version?

    Also I noticed in the example Dockerfile you use pipenv install --deploy rather than pipenv install --ignore-pipfile ...they seem to have similar meaning, I would like to understand the subtlety of one vs the other.

    (loving pipenv so far though!)

  11. anentropic commented on Mar 13, 2018

    @anentropic

    I just found some more opinion from the pipenv tool itself:

    requirements.txt found, instead of Pipfile! Converting…
    Warning: Your Pipfile now contains pinned versions, if your requirements.txt did.
    We recommend updating your Pipfile to specify the "*" version, instead.
    
  12. uranusjr commented on Mar 14, 2018

    @uranusjr
    Member

    This thread is quite old, but since it emerges again I guess it is best to make a definite, up-to-date statement. As of March 2018, the answer to this question is yes, you should always commit the lock file. Always.

  13. mmohaveri commented on Apr 1, 2018

    @mmohaveri

    @uranusjr could you please explain why?

    what has changed in March 2018 that changed the answer from "generally yes" to "always yes"?

    What about the issue you explain earlier, is it fixed?

    Using a lockfile from a different OS is fine if all your packages are modern and well-behaved (either platform-agnostic or have good cross-platform support). Otherwise Pipenv can do things wrong, like installing dependencies that don’t work, or not installing all needed dependencies.

  14. techalchemy commented on Apr 1, 2018

    @techalchemy
    Member

    Nothing is different. You should commit it to version control. If there are os-specific markers they should be included automatically. Because setup.py files are non-deterministic, it is possible to resolve a package on linux and find that it resolves differently on windows, but there is nothing we or anyone else besides the package maintainer can do about that. You won't know that's a problem unless you encounter it. If and when you do, simply re-lock and see the diff.

  15. 107 remaining items

  16. added a commit that references this issue on Aug 21, 2024
  17. added a commit that references this issue on Oct 2, 2024
  18. added a commit that references this issue on Oct 11, 2024
  19. added a commit that references this issue on Dec 18, 2024
  20. added 2 commits that reference this issue on Dec 21, 2024
  21. added a commit that references this issue on Jul 9, 2025
  22. added a commit that references this issue on Oct 2, 2025
  23. added a commit that references this issue on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions