bmatcuk / stylelint-lsp

A stylelint Language Server
MIT License
48 stars 4 forks source link

`Command not found: stylelint-lsp` but I see it in the file system? #43

Closed benfrain closed 12 months ago

benfrain commented 1 year ago

Thank you for making this project. I'm having an issue getting it running on one of my systems. Trying to figure out if I have it installed correctly.

I wonder if this is a problem particular to my environment? Running macOS, install has been via internal npm proxy.

I have installed stylelint-lsp as per instructions (tried non global and global installs). Local install is here: ~/.local/share/nvim/spec/

That location is added to my path and all other language servers installed there (eg cssls) working as expected.

I see stylelint-lsp in my local file system like this:

stylelint-lsp
  __mocks__
  node_modules
  src
  test
.eslintignore
.eslintrc.js
.npmignore
.prettierrc.json
.travis.yml
jest.config
LICENSE
package.json
README.md
tsconfig.build.json
tsconfig.json
yarn.lock

When I run stylelint-lsp from the command line I get zsh: command not found: stylelint-lsp.

When I try and run from Neovim I get: Spawning language server with cmd:stylelint-lspfailed. The language server is either not installed, missing from PATH, or not executable.

Are there any tests I can perform to check that stylelint-lsp is installed correctly?

bmatcuk commented 1 year ago

Hmm, I assume when you say you've installed "as per the instructions", you're referring to these instructions, since you're using nvim?

When you npm install -g stylelint-lsp, npm should create a symlink to stylelint-lsp/dist/index.js in a global npm bin directory, which should be set in your shell's PATH environment variable. If that's not working, there's some issue with the way npm is setup in your environment. This stackoverflow question might give you some ideas.

If you've installed node via some sort of version manager such as asdf, you may need to run some sort of "reshim" command after installing a package globally so that the version manager can symlink the bin symlinks, lol. In asdf, I believe it would be asdf reshim nodejs, for example.

benfrain commented 1 year ago

Hi Bob, thanks for the reply. Outside of my corporate setting, this is working fine. Inside, to install anything globally it is necessary to sudo it, which then makes accessing it problematic. Could that be the problem?

Does the symink still get made if I install non-globally, npm i stylelint-lsp ?

As a comparison, I have the cssls server installed non-globally and that works as expected, installed alongside stylelint-lsp. (The neovim LspInfo shows me that having a path: cmd: /Users/benfrain/.local/share/nvim/spec/node_modules/.bin/vscode-css-language-server --stdio)

Node itself has been installed using the standard Nodejs.org installer.

Is there a command I can try from CLI to test stylelint-lsp is working there (to remove the Neovim part of the equation)?

Appreciate your input, especially as I realise I have an edge case setup here.

Oh, in case of the high probability I am doing something obviously stupid, here is the config I have for Neovim:

require("lspconfig").stylelint_lsp.setup({
  filetypes = { "css", "scss" },
  root_dir = require("lspconfig").util.root_pattern("package.json", ".git"),
  settings = {
    stylelintplus = {
      -- see available options in stylelint-lsp documentation
    },
  },
  on_attach = function(client)
    client.server_capabilities.document_formatting = false
  end,
})
bmatcuk commented 1 year ago

Hmm, interesting... I wonder if you could update the cmd with the fullpath to stylelint-lsp? For example:

require("lspconfig").stylelint_lsp.setup({
  cmd = { '/full/path/to/stylelint-lsp/dist/index.js', '--stdio' },
  filetypes = { "css", "scss" },
  etc etc etc
})

I also wonder if you might need to specifically run it with node, such as:

require("lspconfig").stylelint_lsp.setup({
  cmd = { 'node', '/full/path/to/stylelint-lsp/dist/index.js', '--stdio' },
  filetypes = { "css", "scss" },
  etc etc etc
})
benfrain commented 1 year ago

Sorry Bob, I don't see a dist folder in there? The Files/Folders I do see are listed in the first comment.

benfrain commented 1 year ago

In other news, when installed out of corporate environment, I see the kind of file structure, and symlinked stylelint-lsp bin file you were expecting:

image

No idea why in corporate situation I am seeing what looks like a 'non built' or 'source' version of the package (as listed in first post)?

bmatcuk commented 1 year ago

No dist folder?! The plot thickens! That's really strange because npm packages are basically like tarballs... the files should be there when npm downloads the package! No idea what's going on...

Perhaps instead of installing the npm package, you could just git clone the repo and build from source? Would just be a yarn install followed by yarn run build.

benfrain commented 1 year ago

Thanks @bmatcuk Iโ€™ll try that when next in the office (Monday) ๐Ÿ‘

benfrain commented 1 year ago

I'll close the loop here eventually but as we don't have Yarn available to us in the corporate environment, and it would seem this is entirely a location/environment dependent oddity, I have asked our IT security team to investigate and possibly re-download etc.

bmatcuk commented 1 year ago

You can probably use npm to install the dependencies, too... there's no lock file, but I think the dependency versions in package.json are "tight" enough that you won't get some crazy, incompatible version.

benfrain commented 1 year ago

Thanks @bmatcuk I am now convinced some mistake was made when getting the package into our system originally. I have requested it to be downloaded again but some of the feedback I have received is that some dependencies were not automatically pulled in as they are now considered deprecated:

npm WARN deprecated stylelint/postcss-markdown@0.36.2
npm WARN deprecated stylelint/postcss-css-in-js@0.37.3

Presume these are dependencies of stylelint (see that it is v13x rather than v15x that is current)?

bmatcuk commented 1 year ago

Ya... I have started working on updating this project, but it's taking a while. Life's busy ๐Ÿ˜† But I should have some time this weekend.

benfrain commented 1 year ago

@bmatcuk thatโ€™s great to hear. You have Paypal or something so I can say thanks with a beer/caffeinated beverage?

bmatcuk commented 1 year ago

No worries... I just published stylelint-lsp v2.0.0. I've updated all the dependencies and confirmed it is working for me in neovim v0.8.0 (though, fix-on-save does not work because neovim was missing the feature until v0.9.0 and I haven't updated yet). Give a try... hopefully it'll work for you =)

benfrain commented 1 year ago

Thanks @bmatcuk Iโ€™ll get the ball rolling on it Monday and report back ๐Ÿ‘๐Ÿ‘๐Ÿ‘

benfrain commented 12 months ago

Works perfectly, thanks @bmatcuk (I'm on Neovim 0.9.4)