Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#11016 closed (wontfix)

manage.py not finding custom commands when run from different directory (or through a symlink in a different directory)

Reported by: icyhandofcrap Owned by: nobody
Component: Core (Management commands) Version: 1.1-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

http://code.djangoproject.com/ticket/5825

Similar to the above case, but manage.py will not find custom commands if called through a symlink from a different directory or from a different directory other than the project directory.

Attachments (4)

managepath.diff (633 bytes ) - added by icyhandofcrap 16 years ago.
managepath.2.diff (633 bytes ) - added by icyhandofcrap 16 years ago.
managepath.3.diff (677 bytes ) - added by icyhandofcrap 16 years ago.
test.py (261 bytes ) - added by anonymous 16 years ago.

Download all attachments as: .zip

Change History (14)

by icyhandofcrap, 16 years ago

Attachment: managepath.diff added

comment:1 by icyhandofcrap, 16 years ago

The attached patch attempts to resolve the path of manage.py if it is a symbolic link, and also gets the parent directory of manage.py, not relying on getcwd()

comment:2 by Alex Gaynor, 16 years ago

This path uses the Python2.5 ternary conditional syntax, please write this in a way that is 2.3 compatible.

by icyhandofcrap, 16 years ago

Attachment: managepath.2.diff added

by icyhandofcrap, 16 years ago

Attachment: managepath.3.diff added

comment:3 by icyhandofcrap, 16 years ago

okay changed.

comment:4 by Eric Holscher, 16 years ago

Needs tests: set

by anonymous, 16 years ago

Attachment: test.py added

comment:5 by anonymous, 16 years ago

I'm not sure how I would do unit tests for this, but this is a demo of the code. Make symbolic links, run it from different directories, etc. and it will print out the parent directory of the script itself. Of course, doesn't work with hard links.

comment:6 by Ulrich Petri, 16 years ago

I can't reproduce the problem (Mac OS 10.5, Python 2.5, Django trunk r10697)

comment:7 by anonymous, 16 years ago

Well the issue is if under installed apps, you have:

'myproject.app',

instead of

'app'.

Then when you run manage.py from a different directory, manage.py doesn't detect that it is in the myproject directory already and fails to import app. Then it doesn't import the custom commands.

comment:8 by Eric Holscher, 16 years ago

If that is the case, I think we can punt this to 1.2 with a "don't do this". We were talking about documenting that you should always import your apps with the full path at the sprints in Prague.

comment:9 by Jacob, 16 years ago

Resolution: wontfix
Status: newclosed

Yes, you should always use absolute paths for INSTALLED_APPS, and everywhere else, too. This is really just another incarnation of the "project" abstracting being confusing and hurting users later on; in this case, a basic understanding of PYTHONPATH explains what's going on here.

comment:10 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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