Closed Bug 662761 Opened 13 years ago Closed 13 years ago

CFX: Fails to resolve symlinks.

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: arky, Assigned: arky)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Build Identifier: 

Launching cfx from a symlink fails with a import error

Reproducible: Always

Steps to Reproduce:
1.Symlink (ln -s addon-sdk/bin/cfx /opt/local/bin/cfx) 
2.Launch cfx ($ cfx [init|test| docs]
3.Cfx fails with a import error
Attached patch bin/cfx pathSplinter Review
Attachment #537975 - Attachment is patch: true
Attachment #537975 - Attachment mime type: application/octet-stream → text/plain
Comment on attachment 537975 [details] [diff] [review]
bin/cfx path

Brian: I thought you were the best one to review this?

I don't see why using a symbolic link is helpfull as we have to do: 
  source bin/activate
but this patch seems really small, so if it can help some usecases ...
Attachment #537975 - Flags: review?(warner-bugzilla)
Comment on attachment 537975 [details] [diff] [review]
bin/cfx path

The os.path.realpath() part is the important bit. But I think it's better to use sys.argv[0] instead of __file__, because __file__ isn't always present. (this happens in the bundled executables created by "freezing" tools like py2exe which zip up the python interpreter and all the libraries that a given program uses). See http://stackoverflow.com/questions/606561/how-to-get-filename-of-the-main-module-in-python for more details.

I'll r+ a version that does os.path.realpath(sys.argv[0]) .

This is actually pretty useful. bin/cfx is clever enough to set up all the necessary $PATH/$CUDDLEFISH_ROOT/sys.path pieces on its own, based upon which 'cfx' you're running, even if you haven't previously done an 'activate'. The benefit of 'activate' is that 'cfx' gets put in your path, so you don't need to remember where you put it. But if you always use the same SDK, then using a symlink from ~/bin/cfx to SDK/bin/cfx would be more convenient than using 'bin/activate', and would actually work with a patch like this.
Attachment #537975 - Flags: review?(warner-bugzilla) → review-
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → Future
Brian, can you land this with the change you want?
Assignee: nobody → hitmanarky
Target Milestone: Future → 1.2
Landed, in https://github.com/mozilla/addon-sdk/commit/2e07b56b4b734880ae207e8b007857e962ebe339
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: