Comments (18)
It turns out that I was erroneously seeing the couldn't find executable error message, which I improved in 32a2019. This is still an issue, but now the message is much more helpful:
env: node: No such file or directory
from sublime-import-js.
@lencioni Can you try setting the executable path to:
/usr/bin/env PATH=/path/to/directory/that/contains/node /path/to/importjs
from sublime-import-js.
I've started using nodenv, so I'm likely to hit this issue too. I found sublime-3-shell-exec while googling, and it looks like we could use the same technique they do here:
https://github.com/gbaptista/sublime-3-shell-exec/blob/master/ShellExec.py#L169
from sublime-import-js.
@janpaul123 good thought, but I still get the couldn't find executable error with that.
@trotzig good digging, but the only real difference I see there is they are using shell=True
which doesn't seem to help here.
from sublime-import-js.
Unfortunately, your fix does not work for me.
In a regular shell, running echo $PATH
gives me:
/Users/joe/.nvm/versions/node/v4.4.3/bin:/Users/joe/bin:/Users/joe/.shells/bin:/usr/local/bin:/Users/joe/.rbenv/shims:/Users/joe/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/joe/bin:/Users/joe/.shells/bin:/Users/joe/.rbenv/shims:/Users/joe/.rbenv/bin:/usr/local/share/python:/Users/joe/.rbenv/bin:/Users/joe/.rbenv/shims:/usr/local/share/python
But when I look in the Sublime console, I can see that PATH
is set to '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
, which doesn't have the necessary path for nvm.
If I have no executable
configuration, I get the nice custom error message we have. If I set my configuration to this:
{
"executable": "/Users/joe/.nvm/versions/node/v4.4.3/bin/importjs"
}
I get
Error when executing importjs:
env: node: No such file or directory
This is what I see logged in the console:
['/Users/joe/.nvm/versions/node/v4.4.3/bin/importjs', 'fix', '/Users/joe/import-js-simple-project/js/index.js']
error: Error when executing importjs:
env: node: No such file or directory
I believe that this is due to the PATH
not including "/Users/joe/.nvm/versions/node/v4.4.3/bin" which is added by my .zshrc file.
I think we might be able to try to execute ~/.nvm/nvm.sh
before grabbing the PATH
and then we'll be all set.
from sublime-import-js.
Isn't your .zshrc
sourced when you run /bin/zsh
? Can you help me debug this for nvm? :)
from sublime-import-js.
Hmm, it is sourced when I run /bin/zsh
. I tried running /bin/zsh -l -c 'echo $PATH'
in my terminal just now, which should give a login shell, which should source my .zshrc
file, and it gives me what looks like a good PATH
with the nvm stuff in it so that seems to be correct. But for some reason it isn't when run in the plugin...
from sublime-import-js.
the value of out
specifically here is __SUBL_PATH__/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin__SUBL_PATH__
which is missing a bunch of stuff.
from sublime-import-js.
I've checked the value of os.environ['SHELL']
and it is /usr/local/bin/zsh
which is good.
from sublime-import-js.
I tried putting this in a test.py
file:
import os
import subprocess
out = subprocess.Popen(
[os.environ['SHELL'], '-l', '-c',
'echo "__SUBL_PATH__${PATH}__SUBL_PATH__"'],
env=os.environ,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
).communicate()[0].decode()
path = out.split('__SUBL_PATH__', 2)
print(path)
and I ran it with python test.py
and it prints a good PATH
. The plot thickens.
from sublime-import-js.
print(os.environ['PATH'])
in the sublime plugin gives me the short path without the stuff I need, and in my test.py it gives me the good path.
from sublime-import-js.
I think it matters if you launch Sublime from the shell or not. See also https://github.com/int3h/SublimeFixMacPath
from sublime-import-js.
Interesting. Unfortunately, installing SublimeFixMacPath doesn't seem to help me. I'm also having a hard time trying to figure out how to launch Sublime from the shell (where is subl
located?)
from sublime-import-js.
It might be worth looking at what SublimeLinter does for this. Links:
- http://www.sublimelinter.com/en/latest/usage.html#how-linter-executables-are-located
- http://www.sublimelinter.com/en/latest/troubleshooting.html#debugging-path-problems
from sublime-import-js.
I used code directly taken from SublimeLinter in a6e27c5. I probably missed some essential part though.
from sublime-import-js.
Oh that's right. It is possible that this just won't work with how my environment is set up too. Actually, according to http://www.sublimelinter.com/en/latest/troubleshooting.html#adjusting-shell-startup-files that method will not source .zshrc
. I moved my nvm PATH stuff into .zprofile
and it seems to work.
from sublime-import-js.
I just found this in the SublimeLinter docs:
When SublimeLinter starts up, it runs your shell as a login shell to get the PATH. This forces the shell to read the “profile/env” file, but for most shells the “rc” file is not read. There is a very good reason for this: performing initialization that only relates to interactive shells is not only wasteful, it will in many cases fail if there is no terminal attached to the process. By the same token, you should avoid putting code in the “profile/env” file that has any output (such as motd or fortune), since that only works with interactive shells attached to a terminal.
from sublime-import-js.
Just noticed that you found the same thing.
from sublime-import-js.
Related Issues (18)
- Make sublime plugin async HOT 5
- Python error: Can't convert 'NoneType' object to str implicitly
- Broken Pipe HOT 33
- Fix all imports freezes Sublime_text 3 HOT 5
- How can we configure .importjs.js which is documented in https://github.com/Galooshi/import-js? HOT 3
- Importjs for Angular5 HOT 3
- OSError: [Errno 22] Invalid argument HOT 4
- Code of conduct link is invalid in CONTRIBUTING.md HOT 2
- Doesn't work with [email protected] HOT 3
- Not importing prop-types HOT 4
- .import.js config file not work
- Couldn't find executable importjsd. HOT 2
- add import statement in top of a html file HOT 2
- Running ImportJS command... Commands no longer working HOT 2
- .sublime-settings are ignored - documentation error?
- Mysterious line-break inserted HOT 6
- When fixing and asking for selections, does not import words that do not need prompts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sublime-import-js.