vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.58k stars 663 forks source link

"psalm.phar --language-server" does not start correctly and may result in an error. #5456

Open yaegassy opened 3 years ago

yaegassy commented 3 years ago

Description

I want to start the language server with phar, but in some cases I get an error.

The psalm and psalm-language-server installed by "composer" seem to work fine.

Is this a known bug?

Repro

  1. Download psalm.phar to a location of your choice (e.g. /tmp/psalm.phar)
  2. chmod a+x /tmp/psalm.phar
  3. Install vimeo/psalm in project. (composer require --dev vimeo/psalm)
  4. Create psalm.xml in the project root (e.g. /tmp/psalm.phar --init or ./vendor/bin/psalm --init)
  5. If you run /tmp/psalm.phar --language-server in the project root, you will get an "error".

Note

In this case, the error seems to occur if vimeo/psalm is installed in the project.

After uninstalling "vimeo/psalm", /tmp/psalm --language-server started correctly.

Screenshot

psalm-phar-lsp-error
weirdan commented 3 years ago

Is there a specific reason why you're using both phar and composer-installed Psalm?

yaegassy commented 3 years ago

@weirdan Thanks for the reply.

As an example of use, if it is a phar file in an editor (e.g. VSCode extension or Vim, Emacs), installation is easy.

I thought it would be nice if "LS" could be started with a phar file without errors, regardless of whether the project has psalm or not.

When I set this phar file in psalm-vscode-plugin, it crashes and times out, and the same happens in Vim and Emacs plugins.

yaegassy commented 3 years ago

A similar issue was found in psalm-vscode-plugin. https://github.com/psalm/psalm-vscode-plugin/issues/33