lexicalunit / atom-isort

Organize python imports using isort
https://atom.io/packages/atom-isort
MIT License
3 stars 3 forks source link

Failure to import isort when file opened via terminal cmd+click #26

Open jarekwg opened 4 years ago

jarekwg commented 4 years ago

OK this is super weird, hear me out.

If i open my atom with atom . and then navigate through files using the tree view and save them, isort applies properly.

However, if I bring up a file in atom by cmd+clicking it from my terminal, i get an import error as soon as the file opens. This error then reappears each time i attempt to save, as well as time i open another file, even via atom tree view. isort effectively stops working until i kill and restart my atom. Here's the error that comes up: image

Using isort 5.0.7, python 3.8 Lemme know if i can provide any additional info that might help you reproduce/debug!

jarekwg commented 4 years ago

Ha! That was shortlived; found a fix. Still suspicious though... I went into my iterm2 preferences, and changed cmd+click behaviour from image to image

I'll leave the issue open, as I wasn't having this issue with the previous python-isort atom plugin, so something fishy is still amiss if you're interested in having a look. However my problem is fixed.

jarekwg commented 4 years ago

Ok, this issue is back with the latest atom-isort release, and iterm settings don't seem to be getting around it.. Same error, exactly as I described it in the opening description. Opening a file with cmd+click from command line causes this extension to freak out and remain broken until atom is restarted.. Not sure what other info i can give to help debug this one..

e: in some cases error message is this instead: image

theshoals commented 4 years ago

I believe this error is caused by a race condition: https://github.com/lexicalunit/atom-isort/pull/30

jarekwg commented 4 years ago

Hmm, got excited too soon. Error still around after updating to 3.2.2. It looks like #30 has had some effect, as I no longer see the EPIPE error when the file opens, however everything else I described earlier still happens. On save, I still get: image (one message per save), across all files until atom is restarted.

theshoals commented 4 years ago

That error indicates that the invoked Python executable doesn't have an associated isort module.

I think it'd be useful to see if your PATH differs when Atom is opened via the command line and via cmd+click to see if different Python executables are being used.

Can you run process.env.PATH in the Dev Tools Console (View > Developer > Toggle Developer Tools) and report the value for both methods of opening Atom?

jarekwg commented 4 years ago

When working: "/usr/local/opt/helm@2/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" When borked: "/usr/bin:/bin:/usr/sbin:/sbin"

Interesting..

So my isort lives under: /Library/Frameworks/Python.framework/Versions/3.8/bin/isort

After explicitly listing isort dir in python-isort settings, i now have: Working: "/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/opt/helm@2/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" Borked: "/usr/bin:/bin:/usr/sbin:/sbin"

This means

@theshoals This is smelling more like an issue with atom than with python-isort specifically.. what do you think?

lexicalunit commented 4 years ago

It's been an issue with Atom in the past and I thought it had been fixed, but a quick search I did just now turned this up: https://github.com/atom/atom/issues/14924 so maybe it hasn't been fixed, or it was and there's been a regression.

I don't actually use Atom anymore so if someone else wants to take over this project, let me know and I can hand it over.

jarekwg commented 4 years ago

It's been an issue with Atom in the past and I thought it had been fixed, but a quick search I did just now turned this up: atom/atom#14924 so maybe it hasn't been fixed, or it was and there's been a regression.

I don't actually use Atom anymore so if someone else wants to take over this project, let me know and I can hand it over.

Ah nice find. I had a look through atom issues, but didn't trawl back to 2017. There's no mention of cmd+click there, so potentially they fixed it for some cases but not others.

I've been meaning to move to vscode, but there are just some things atom does nice that make it hard to make the switch..

Anyway, thanks! will direct further info on this issue at atom/atom#14924 directly.