csscomb / sublime-csscomb

Sublime plugin for CSScomb—CSS coding style formatter
398 stars 61 forks source link

Still not working well with nvm #80

Closed arlodesign closed 5 years ago

arlodesign commented 7 years ago

Mac OS X El Capitan 10.11.6 Sublime Text 3, Build 3114 Node v6.5.0, installed via nvm (though I haven't gotten any version of node to work)

I know a lot of folks have posted issues concerned with using this package with node installed via nvm. I've now tried both updating the sublime settings, both user and package level, as well as symlinking /usr/local/bin/node to the latest version. No such luck.

I've installed CSScomb globally:

$ csscomb --version
3.1.7

Contents of ~/Library/Application Support/Sublime Text 3/Packages/User/CSScomb.sublime-settings

{
    "node-path" : ":/Users/arloguthrie/.nvm/versions/node/v6.5.0/bin/node"
}

I've tried it with and without the : at the beginning. I've tried setting this value in ~/Library/Application Support/Sublime Text 3/Packages/CSScomb/CSScomb.sublime-settings, as well.

My symlink

lrwxr-xr-x  1 myuser  admin    53B Aug 29 16:00 /usr/local/bin/node -> /Users/myuser/.nvm/versions/node/v6.5.0/bin/node

The error I get in the Sublime console every time I try to run CSScomb

Traceback (most recent call last):
  File "/Users/myuser/Library/Application Support/Sublime Text 3/Packages/CSScomb/CSScomb.py", line 45, in comb
    env=self.get_env(), shell=self.is_windows())
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1448, in _execute_child
NotADirectoryError: [Errno 20] Not a directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "/Users/myuser/Library/Application Support/Sublime Text 3/Packages/CSScomb/CSScomb.py", line 27, in run
    combed = self.comb(originalBuffer, syntax, config)
  File "/Users/myuser/Library/Application Support/Sublime Text 3/Packages/CSScomb/CSScomb.py", line 48, in comb
    '$PATH by running `node -v` in your command-line.')
Exception: Couldn't find Node.js. Make sure it's in your $PATH by running `node -v` in your command-line.

…which, of course, provides this:

$ node -v
v6.5.0

What I've tried

SublimeLinter is still working fine. I'm using SublimeLinter-contrib-eslint (which uses the setting node_path with an underscore), and it's working just fine pointing at Node v6.5.

Any help you can provide is greatly appreciated. Thank you.

arlodesign commented 7 years ago

Also confirmed that /Users/myuser/.nvm/versions/node/v6.5.0/bin is in my $PATH

joeczucha commented 6 years ago

@arlodesign

Trying adding this to your CSSComb config:

{
  "node-path": ":/Users/myuser/.nvm/versions/node/v6.5.0/bin"
}

(note the colon before /Users)

Worked for me, installing Node with NVM.

Boobooka commented 5 years ago

@joeczucha I don't know but i think you are using osx maybe? I've looked into the python code, and I think the above mentioned node-path setting is only used if you are on a mac. I didn't dig myself into the real problem here but the subprocess.Popen method wich is used to call node does not use the $PATH variable. So i've just hard coded the path into the method call in CSScomb.py at line 43.

p = Popen([self.get_node_path() + 'node', COMB_PATH] + [syntax, config, folder],
                stdout=PIPE, stdin=PIPE, stderr=PIPE,
                env=self.get_env(), shell=self.is_windows())

In this case you may want to include a slash at the end of the path. Now it is working for me at least.

arlodesign commented 5 years ago

This appears to be resolved.