heroku-buildpack-python: Deploy fails due to outdated Pipfile.lock
Our heroku builds have started failing today with the error message
Your Pipfile.lock (<local hash>) is out of date. Expected: (<new hash>)
I notice that you have bumped the pipenv version today, and I have also updated my local pip (10.0.1) and and pipenv (2018.05.18) installations. However, I am unable to get my Pipfile.lock hash to change to <new hash> -running pipenv lock does not change the hash at all.
I am at a loss as to what is causing my local Pipfile.lock hash to be different to the one generated in the heroku build, or how to fix the problem.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 15 (10 by maintainers)
Commits related to this issue
- Stop using Pipfile due to a bug in pipenv https://github.com/heroku/heroku-buildpack-python/issues/704 — committed to InternetSemLimites/PublicAPI by cuducos 6 years ago
- Stop using Pipfile due to a bug in pipenv https://github.com/heroku/heroku-buildpack-python/issues/704 — committed to InternetSemLimites/PublicAPI by cuducos 6 years ago
- Allow users to override the version of pipenv used This also starts tracking which Pipenv version users are selecting to use. Closes #702 Closes #704 Closes #706 Closes #727 — committed to heroku/heroku-buildpack-python by sigmavirus24 6 years ago
Just to report some success in solving it and another work around:
@mcescalante and I ran into the same issue today. In our case it was fixed by removing a requirements that was to be installed from GitHub (c.f. https://github.com/OpenHumans/oh-fitbit-integration/pull/16/files#diff-1e61a31bf9b94805f869dc4137ec1885L20).
After removing the corresponding requirement the build on heroku would go through without any problems. As an alternative to that
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python\#v134did the trick as well.Environment variables set in the app’s config are not set in the environment during the build by default - instead individual steps during the build have to load them in from
ENV_DIR(using thesub_envhelper). See: https://devcenter.heroku.com/articles/buildpack-api#bin-compileI presume this is intended to prevent the build being broken by an app having variables set that shouldn’t be, but it does mean that it’s currently not possible to set
SKIP_PIPENV_INSTALLmanually (perhaps the maintainers of this buildpack would be open to changing this?).For now an alternative workaround (instead of pinning to an old buildpack version), would be to use the
pre_compilehook to deletePipfileandPipfile.lockbefore they are detected and used: https://github.com/heroku/heroku-buildpack-python/blob/master/bin/steps/hooks/pre_compileTo do that, create a script named
bin/pre_compilein your app’s repository, containing:@adamkowalczyk It should be https://github.com/pypa/pipenv/issues/2219 and fixed in https://github.com/pypa/pipenv/pull/2301
Just implemented it and it works like a charm!
This will allow us to keep dependencies under pipenv management / enjoy its support for working with virtualenvs, and, at the same time, hopefully never again waste days on fixing pipenv related problems on Heroku / always have a stable
requirements.txtfallback.@edmorley as to your additional point, thanks for this valuable hint as well, I’ll just add a check to our CI script to compare
requirements.txtandpipenv lock -routput to avoid forgetting to updaterequirements.txt, and hitting resulting problems w.r.t. systems parity.I wish Heroku engineers were as helpful and responsive as you guys, so glad I stumbled upon this issue 👍