[Django]-No Procfile and no package.json file found in Current Directory – See run-foreman.js

3👍

It might caused by wrong Procfile syntax.

Try to remove any comment from your Procfile. It works in my case.

My original Procfile:

# Some comment here

web: python start.py --port %PORT%

After removing the comment, no more errors occur.

web: python start.py --port %PORT%
👤Leon

1👍

I had same problem with tmp directory.
I could solve it by removing from .gitignore. check Procfile in .gitignore

👤mrm78

1👍

BLUF: Try verifying your Procfile is actually saved as a UTF-8 file


How to debug your issue better:

This is a generic error heroku-cli returns whenever it can’t parse your Procfile, and unfortunately it’s logging does a poor job of telling you what the problem is.

For me, I ran into this error when I tried creating the Procfile in Pycharm on Windows

$ heroku local
[WARN] Cannot read property '1' of null
[FAIL] No Procfile and no package.json file found in Current Directory - See run --help
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Index.run (/usr/local/lib/heroku/node_modules/@heroku-cli/plugin-local/lib/commands/local/index.js:30:38)
    at Index._run (/usr/local/lib/heroku/node_modules/@oclif/command/lib/command.js:44:31)

Turns out, the heroku server is gives much better error messages!

When I tried pushing the changes directly to heroku that I got a real lead towards the true root cause:

$ git push heroku main
Counting objects: 102, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (96/96), done.
Writing objects: 100% (102/102), 33.93 KiB | 808.00 KiB/s, done.
Total 102 (delta 31), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
git bremote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
remote: -----> Using Python version specified in runtime.txt
remote: Traceback (most recent call last):
remote:   File "/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/vendor/runtime-fixer", line 8, in <module>
remote:     r = f.read().strip()
remote:   File "/usr/lib/python3.8/codecs.py", line 322, in decode
remote:     (result, consumed) = self._buffer_decode(data, self.errors, final)
remote: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
remote: /tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/bin/steps/python: line 5: warning: command substitution: ignored null byte in input
remote: ) is not available for this stack (heroku-20).
remote:  !     Aborting.  More info: https://devcenter.heroku.com/articles/python-support
remote:  !     Push rejected, failed to compile Python app.
remote:
rremote:  !     Push failed
anremote: Verifying deploy...
remote:
remote: !       Push rejected to salty-ocean-58897.
remote:
To https://git.heroku.com/salty-ocean-58897.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/salty-ocean-58897.git'

Specifically, note the line:

remote: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

That’s what pointed me in the right direction and led me to realizing Pycharm had created my Procfile, runtime.txt, and requirements.txt files as utf-16 files. Converting them to utf-8 fixed the error.

Leave a comment