Do Not Push The Pipfile To GitHub

You may avoid this headache when deploying to Heroku

Renan
3 min readOct 31, 2021

Deploying a Django project in Heroku can be a quite instructive experience. That is, if like myself, you prefer to learn from troubleshooting rather than going through the entire documentation.

Last week was one of those learning experiences: file structure reviewed, environmental variables set and project dependencies updated… here comes deployment time!

Successfull Deployment Is No Guarantee

No issues in the Build Log, right? Think again…

Heroku script requires you to include certain files in the project, and then it will follow the instructions written in them. As long as you provide minimum instructions, the app will be smoothly deployed.

But that doesn’t mean the app will work. Like it happened to me, after a hassle-free deployment, I got the “Application error” page.

It’s True, You Should Check the Log

gunicorn: command not found

I battled my internal ego, and gave in… I checked the log.

And it was clear… “gunicorn: command not found” states for gunicorn not found. That (almost certainly) means that gunicorn was not even installed in the first place.

A quick peek to the Build Log and… indeed, python… OK, pip… OK, setuptools, wheel, SQLite3… OK OK OK. Where are gunicorn, psycopg2, requests… and by the way, where is Django itself?!

Heroku’s Free Will

If you review the Buid Log, you will notice that gunicorn nor Django were ever installed, even though they were listed in the requirements file. Why?

If Pipfile is there, Heroku will ignore the requirements file

The Build Log says: “Installing dependencies from Pipfile…”. As I found out later, my Pipfile didn’t have the dependencies updated, which caused the deployment to be installed with minimum packages and libraries.

And Heroku never even checked the requirements file, because it will install the project’s dependencies listed in the Pipfile OR in the requirements — in that order.

Keep It Out

If you are used to deploy Django apps to Heroku using the requirements file, I advise you to keep it that way and make sure it is duly updated, as you normally would.

Pipfile is an essential file for your development virtual environment, but make yourself a big favor: keep it off the repository by adding a special line for it in your gitignore list, and enjoy!

--

--

Renan

I write to organize thoughts and ideas in a rational way about technology, health, lifestyle and productivity.