Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23691 closed Uncategorized (invalid)

devserver autoreload: OSError: [Errno 2] No such file or directory

Reported by: Sergei Maertens Owned by: nobody
Component: Core (Management commands) Version: 1.7
Severity: Normal Keywords: development server, autoreload
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm running into an issue with the autoreload from the dev server (might be related to #23083).

Python version: 2.7.8
Virtualenv (with virtualenvwrapper), version 1.11.6
Django 1.7.0
OS: Arch Linux

Usually I run the development server from the directory containing manage.py by invoking ./manage.py runserver.

This leads to the attached stacktrace. When I run it by using the absolute path to the file, it's fine.

Upon further investigation I noticed that at the end of manage.py os.getcwd() prints the expected cwd, but at the point where the exception occurs Python/Django seems to think I'm in my virtualenv directory.

Expected cwd: /home/bbt/coding/maykin/leesrijk/src/
Virtualenv location: /home/bbt/coding/.virtualenvs/leesrijk/
Reported cwd in reload.py: /home/bbt/coding/.virtualenvs/leesrijk

I'm not sure if this is a Django bug or if something else is going on, but it started happening with Django 1.7, no issues on 1.6.

Attachments (2)

stacktrace.txt (2.2 KB ) - added by Sergei Maertens 10 years ago.
pip.txt (666 bytes ) - added by Sergei Maertens 10 years ago.
Output from pip freeze

Download all attachments as: .zip

Change History (11)

by Sergei Maertens, 10 years ago

Attachment: stacktrace.txt added

comment:1 by Baptiste Mispelon, 10 years ago

Hi,

I have the same OS, the same Python and virtualenv versions yet I can't seem to reproduce your issue:

$ python2 --version
Python 2.7.8

$ virtualenv --version
1.11.6

$ mkvirtualenv -p /usr/bin/python2 djangobug23691
Running virtualenv with interpreter /usr/bin/python2
New python executable in djangobug23691/bin/python2
Also creating executable in djangobug23691/bin/python
Installing setuptools, pip...done.

(djangobug23691)$ pip install Django==1.7.0
Downloading/unpacking Django==1.7.0
  Downloading Django-1.7-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: Django
Successfully installed Django
Cleaning up...

(djangobug23691)$ django-admin startproject djangobug23691
(djangobug23691)$ cd djangobug23691/
(djangobug23691)$ ./manage.py migrate
Operations to perform:
  Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying sessions.0001_initial... OK

(djangobug23691)$ ./manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
October 20, 2014 - 15:03:14
Django version 1.7, using settings 'djangobug23691.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[20/Oct/2014 15:03:16] "GET / HTTP/1.1" 200 1759

Am I missing something?

comment:2 by Sergei Maertens, 10 years ago

I'm not sure, colleagues running Debian/Windows report no issues either. I'm attaching the output from pip freeze, maybe it's related to some library there.

Also for completeness, the template used for startproject: https://bitbucket.org/maykinmedia/default-project

Last edited 10 years ago by Sergei Maertens (previous) (diff)

by Sergei Maertens, 10 years ago

Attachment: pip.txt added

Output from pip freeze

comment:3 by Collin Anderson, 10 years ago

Right, so based on your stacktrace, it seems like _something_ is changing the current working directory. Assuming that's true, maybe the runserver code needs to run abspath on everything it finds? Either that or we need to not support changing the current working directory once django is loaded.

comment:4 by Sergei Maertens, 10 years ago

Resolution: invalid
Status: newclosed

I recently changed to zsh instead of bash and running it in bash looks fine, so there's probably something weird going on in my zsh config. So since this is probably not a django issue, I'm leaving it for what it is.

It's still strange that I have no issues on 1.5 or 1.6 though.

edit: using pyinotify makes it workable, but there is still an error related to manage.py and a changing working dir

Last edited 10 years ago by Sergei Maertens (previous) (diff)

comment:5 by Sergei Maertens, 10 years ago

I managed to track the point of cwd change, it happens in django.utils.autoreload.clean_files, but it seems to be a random point. It's never for the same file. Could this be related to the threading in the dev server?

comment:6 by Sergei Maertens, 10 years ago

Resolution: invalid
Status: closednew

Reopening this ticket since a colleague runs into the same issue

OS: Ubuntu 14.10, fresh install as of today
Python version: 2.7.6
Django version: 1.7

Startproject template: https://bitbucket.org/maykinmedia/default-project

comment:7 by Tim Graham, 10 years ago

Resolution: needsinfo
Status: newclosed

I think we'll need more details in order to reproduce and debug the issue.

comment:8 by Sergei Maertens, 10 years ago

Sure, I have a feeling that it's related to the startproject template. Hopefully I can investigate soon.

comment:9 by Sergei Maertens, 10 years ago

Resolution: needsinfoinvalid
Note: See TracTickets for help on using tickets.
Back to Top