Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test command for PHP Language Server returns true when lsp-clients-php-server-command is nil. #4507

Open
3 tasks done
AlexanderSeto opened this issue Jul 27, 2024 · 0 comments · May be fixed by #4508
Open
3 tasks done
Labels

Comments

@AlexanderSeto
Copy link

AlexanderSeto commented Jul 27, 2024

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

The test command for the PHP Language Server (php-ls) returns true when lsp-clients-php-server-command is nil.

When invoking lsp for the first time, lsp--filter-clients will check all available clients for lsp--supports-buffer? and server-binary-present?. When it checks php-ls, server-binary-present? will rely on the output of the test-command passed to lsp-stdio-connection. I

Since the test-command runs before the command, lsp-clients-php-server-command is never set. This means that it will fail the first condition here, and then will return t.

This results in php-ls appearing in the list of available servers despite not being installed. All the other servers (save for phpactor) have a higher priority. So php-ls will only be run if either no other server is installed, or if only phpactor is installed.


Subsequent invocations of lsp will behave as expected, since the command for php-ls sets lsp-clients-php-server-command.

Steps to reproduce

  1. Fresh emacs
  2. Don't install Intelephense or Serenata
  3. Don't install PHP Language Server
  4. Install phpactor(Optional)
  5. Open a php file

Expected behavior

php-ls shouldn't appear in the available servers list if the PHP language server isn't installed.

Which Language Server did you use?

lsp-php

OS

MacOS

Error callstack

First Invocation:
Command "semgrep lsp" is not present on the path.                                                                                                                                                                                             
Command "/usr/local/bin/phpactor language-server" is present on the path.                                                                                                                                                                     
Command "serenata.phar -u 0" is not present on the path.                                                                                                                                                                                      
Command "semgrep lsp" is not present on the path.                                                                                                                                                                                             
Command "/usr/local/bin/phpactor language-server" is present on the path.                                                                                                                                                                     
Command "serenata.phar -u 0" is not present on the path.                                                                                                                                                                                      
Found the following clients for [php file]: (server-id phpactor, priority -4), (server-id php-ls, priority -3)                                                                                     
The following clients were selected based on priority: (server-id php-ls, priority -3)


Second Invocation:                                                                                                                                        
Command "semgrep lsp" is not present on the path.                                                                                                                                                                                             
Command "/usr/local/bin/phpactor language-server" is present on the path.                                                                                                                                                                     
Command "serenata.phar -u 0" is not present on the path.                                                                                                                                                                                      
[home dir]/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php is not present.                                                                                                                                        
Command "semgrep lsp" is not present on the path.                                                                                                                                                                                             
Command "/usr/local/bin/phpactor language-server" is present on the path.                                                                                                                                                                     
Command "serenata.phar -u 0" is not present on the path.                                                                                                                                                                                      
[home dir]/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php is not present.                                                                                                                                        
Found the following clients for [php file]: (server-id phpactor, priority -4)                                                                                                                      
The following clients were selected based on priority: (server-id phpactor, priority -4)                                                                                                                                                      
Creating watchers for following 25 folders:

Anything else?

I believe I've identified the issue and will be submitting a PR shortly.

@AlexanderSeto AlexanderSeto linked a pull request Jul 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant