bcomnes / sublime-standard-format

:sparkles: Runs standard --fix against the javascript in your ST3 window on save or manually.
https://packagecontrol.io/packages/StandardFormat
MIT License
60 stars 21 forks source link

Nothing happes after installing nvm #61

Closed pito-svk closed 7 years ago

pito-svk commented 7 years ago

Hi, I have an issue after I uninstalled nodejs and installed nvm after that,so I can switch between node versions.

After configuring nvm to load in .zshenv instead of .zshrc, I managed to have working SublimeLinter for standard format, however this package doesn't work after I save file.

In sublime logs I don't have any errors and have "format_on_save": true in package settings.

I am using osx.

Thanks for help.

Edit: also found this issue:

After every file save I get the following error:

b'env: node: No such file or directory\n'

bcomnes commented 7 years ago

Standard format will attempt to calculate your user environment from an interactive shell it spawns on launch. It defaults to using bash, so if you have not configured bash to contain your nvm settings, it probably won't pick up that configuration. SublimeLinter does some black magic to aggressively find user environment settings that we haven't had a chance to implement yet.

Two ideas that might fix it:

What you can do is change the following setting in your sublime standard format user config:

"get_path_command": ["/usr/bin/env", "bash", "-l", "-i", "-c", "echo $PATH"],

to something like

"get_path_command": ["/usr/bin/env", "zsh", "-l", "-i", "-c", "echo $PATH"],

Try restarting sublime after changing this because this only runs once when loading iirc.

The other thing you can try is to replicate your nvm config in .bash{_profile,rc}. That should work as well. There are also ways to create shared config between both zsh and bash if you want.

You can also enable these settings to help while debugging:

"check_version": true,
"logging_on_view_change": true

This will trigger a log message every time you change a view printing the environment settings that standard format finds. It will also attempt to print the version of standard format that is found for a given view.

Let me know if you get it working!

bcomnes commented 7 years ago

If all else fails, or you want the Janky solution, you can add arbitrary search path's to the "PATH": [], field in your user settings. These preside environmental search paths.

pito-svk commented 7 years ago

Thanks, the solution with "get_path_command" works!

bcomnes commented 7 years ago

Sweet! That was easy. I don't use zsh / nvm enough to really test it perfectly. I can add a note to the READ me / install notes.

tennessine commented 7 years ago
wx20170602-134615 2x

mac os、nvm、oh my zsh