Skip to content
This repository has been archived by the owner on Apr 24, 2018. It is now read-only.

heroku Error while running '$ python manage.py collectstatic --noinput'. #3

Open
muxuezi opened this issue Feb 20, 2018 · 2 comments
Open

Comments

@muxuezi
Copy link

muxuezi commented Feb 20, 2018

(flango-BaHqgQZm) ➜  flango git:(master) ✗ git push heroku master
Counting objects: 14, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (14/14), 7.03 KiB | 7.03 MiB/s, done.
Total 14 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote:  !     The latest version of Python 3 is python-3.6.4 (you are using python-3.6.3, which is unsupported).
remote:  !     We recommend upgrading by specifying the latest version (python-3.6.4).
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.6.3
remote: -----> Installing pip
remote: -----> Installing requirements with latest Pipenv…
remote:        Installing dependencies from Pipfile.lock (881329)…
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 15, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
remote:            self.fetch_command(subcommand).run_from_argv(self.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
remote:            self.execute(*args, **cmd_options)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
remote:            output = self.handle(*args, **options)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 189, in handle
remote:            collected = self.collect()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
remote:            for path, storage in finder.list(self.ignore_patterns):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/finders.py", line 125, in list
remote:            for path in utils.get_files(storage, ignore_patterns):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
remote:            directories, files = storage.listdir(location)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/files/storage.py", line 313, in listdir
remote:            for entry in os.listdir(path):
remote:        FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_f52ae90b128b348cb2a6880ecac30818/static'
remote:
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote:
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !	Push rejected to warm-spire-49349.
remote:
To https://git.heroku.com/warm-spire-49349.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/warm-spire-49349.git'
@ghost
Copy link

ghost commented Apr 17, 2018

i was getting the same issue plz give me solution

@GerardoLSJ
Copy link

GerardoLSJ commented Apr 22, 2018

I read the component made by heroku and discover something that fix my problem
https://github.com/heroku/django-heroku/blob/master/django_heroku/core.py

They create the directory /staticfiles/ if it doesnt exist, so I created ALSO /static/ and that solves my problem.

This is my settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))
...
MIDDLEWARE = [...
'whitenoise.middleware.WhiteNoiseMiddleware',
...
]
...
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_TMP = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

os.makedirs(STATIC_TMP, exist_ok=True)
os.makedirs(STATIC_ROOT, exist_ok=True)

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)

///

Actually look at the error:

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_f52ae90b128b348cb2a6880ecac30818/static'

There's no static folder

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants