Skip to content

fix: start the commands of the templates without sh -c or sh -s - #1976

Merged
lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:fix/start-template-commands-without-a-shell
Nov 12, 2026
Merged

lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:fix/start-template-commands-without-a-shell

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #1954 and #1956, both collected in #1943.

sh -c and sh -s (#1954)

LSP4IJ splits a command at its spaces, so sh -c typescript-language-server --stdio gave sh three arguments, and sh -c runs only the first one: the language server started without --stdio. With sh -s, sh reads its commands from the standard input instead: the Ruby LSP template never started ruby-lsp, and the Ruby Debug installer waited for commands.

This takes option 1 of muescha's options, no shell, which his second comment recommends.

  • Templates and installers start their commands directly, as the other templates do:
    • TypeScript, Stylelint, gopls, Harper, Perl, SysML, EO, rust-analyzer and wgsl-analyzer drop sh -c.
    • Ruby LSP starts ruby-lsp, and the installers of Ruby LSP and Ruby Debug run gem install ruby-lsp and gem install debug.
    • The HTML template, which quoted its command correctly, now starts node "…" --stdio, as its Windows command already did.
    • The Windows commands are unchanged.
  • The user guide no longer advises sh -c or cmd /c for the environment variables. LSP4IJ gives the command its environment and looks the command up in that PATH, and a non-interactive shell adds nothing to it. The guide now says to use a shell only for shell syntax, with the whole command in double quotes. The template docs' example and the gopls and rust-analyzer pages show the new commands.
  • Installers split a command given as a string with CommandUtils.createCommands, as LSP4IJ splits the command that starts a language server, instead of split(" "). An argument in double quotes now keeps its spaces. No bundled installer command has quotes or double spaces, so none of them changes.

jq-lsp (#1956)

Its installer, copied from the gopls one, set the command to jq-lsp -mode=stdio, an option of gopls that jq-lsp rejects, so the language server exited right after it was installed. It now sets jq-lsp, as the template starts it, and its hint names jq-lsp instead of gopls.

Not in this PR

  • Servers created before this fix keep their saved command, since LSP4IJ copies a template's command into a server's settings when it creates the server. Most of them got a working command from their installer ("update": true) the first time they started; a Ruby LSP server created from the template didn't. The 0.30.0 change notes (docs: change notes for 0.30.0 #1941) will say to create such a server again, or to remove sh -c or sh -s from its command.
  • The installer check that counts a timeout as success is Installer check: a hanging command counts as installed #1957.

How this was checked

  • BundledTemplateCommandsTest reads every template.json and installer.json of the bundled language servers and debug adapters. It fails on any command that starts with sh, unless it's sh -c with the whole command as one argument. On main it lists the 12 commands this PR fixes.
  • ExecTaskFactoryTest: a string command in an installer keeps an argument in double quotes together, and two spaces make no empty argument. Both tests fail with split(" ").
  • The whole test suite passes locally (1633 tests), except for 7 tests that fail on main on this Mac too: IntelliJ's "File accessed outside allowed roots", since macOS's temporary directory /var is /private/var. CI doesn't hit this.
  • The language servers themselves weren't started; none of them is installed here.

The jq-lsp installer, copied from the gopls one, set the command to
'jq-lsp -mode=stdio' after installing. jq-lsp stops on an option it
doesn't know, so the language server exited at once after it was
installed. The command is now 'jq-lsp', as the template starts it, and
the installer's hint names jq-lsp instead of gopls.

Fixes redhat-developer#1956
LSP4IJ splits a command at its spaces, so 'sh -c typescript-language-server
--stdio' gave sh three arguments, and sh -c runs only the first one: the
language server started without --stdio. The Ruby LSP template and the
installers of Ruby LSP and Ruby Debug used 'sh -s', with which sh reads
its commands from the standard input instead: ruby-lsp never started,
and 'gem install debug' waited for commands.

The templates and installers now start their commands directly, as the
others do. A shell adds no environment variables: LSP4IJ gives the
command its environment and looks it up in that PATH. The user guide no
longer advises sh -c or cmd /c for the environment variables, and says
to give a shell the whole command in double quotes, for shell syntax
only.

An installer now splits a command given as a string as LSP4IJ splits the
command which starts a language server, so an argument in double quotes
keeps its spaces.

Fixes redhat-developer#1954
@lagergren lagergren added this to the 0.30.0 milestone Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Documentation
    • Clarified how commands use configured environment variables and are found through PATH, including when to use a shell.
    • Updated setup examples for several language servers to use direct launch commands.
  • Bug Fixes
    • Corrected the JQ Language Server installation error message and default launch command.
    • Updated bundled language server and debugger templates to launch commands directly where shell execution isn’t needed.

String command parsing now uses CommandUtils.createCommands. Bundled LSP and DAP commands and documentation now use direct execution where shell syntax is not needed. Tests cover command parsing and scan bundled resources for shell-wrapped commands.

Changes: Command execution

Layer / File(s) Summary
Parse installer command strings
src/main/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/ExecTaskFactory.java, src/test/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/ExecTaskFactoryTest.java
String commands now use CommandUtils.createCommands instead of splitting on spaces. Tests cover quoted arguments, repeated spaces, OS-specific values, and array commands.
Update bundled commands and guidance
src/main/resources/templates/dap/ruby-rdbg/installer.json, src/main/resources/templates/lsp/*/template.json, src/main/resources/templates/lsp/*/installer.json, docs/UserDefinedLanguageServer.md, docs/UserDefinedLanguageServerTemplate.md, docs/user-defined-ls/*, src/test/java/com/redhat/devtools/lsp4ij/launching/templates/BundledTemplateCommandsTest.java
Bundled commands remove unnecessary shell wrappers. The jq-lsp installer message and command are corrected. Documentation describes direct execution and shell use. A test scans bundled resources for shell-wrapped commands.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: angelozerr, muescha

Merge Risk: Minimal · up to dbac0

The change removes unnecessary shell wrappers from bundled templates and installers and adds tests for command parsing. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix: start the commands of the templates without sh -c or sh -s" matches the main change. The PR removes sh -c and sh -s wrappers from bundled LSP and DAP templates and installers, and the …
Description check Passed The description is related to the changeset. It explains the sh -c and sh -s problem (#1954), the template and installer changes, the user guide update, the jq-lsp installer fix (#1956), the CommandUt…
Linked Issues check Passed Directly linked issue #1954 has coding requirements. Each is addressed at head dbac0b5:
(1) Remove unneeded sh -c and incorrect sh -s from affected templates and Ruby installers. The raw summary l…
Out of Scope Changes check Passed All changed files relate to #1954 or to the jq-lsp fix that the PR description states (#1956). The jq-lsp installer diff changes the command from jq-lsp -mode=stdio to jq-lsp and corrects the fail…
Full details: Title check

Explanation

The title "fix: start the commands of the templates without sh -c or sh -s" matches the main change. The PR removes sh -c and sh -s wrappers from bundled LSP and DAP templates and installers, and the summary and objectives describe the same change. The title does not mention the jq-lsp installer fix or the installer parsing change, but those are secondary to the main change.

Full details: Description check

Explanation

The description is related to the changeset. It explains the sh -c and sh -s problem (#1954), the template and installer changes, the user guide update, the jq-lsp installer fix (#1956), the CommandUtils.createCommands change in installers, and the tests added. It also lists what is out of scope.

Full details: Linked Issues check

Explanation

Directly linked issue #1954 has coding requirements. Each is addressed at head dbac0b5:
(1) Remove unneeded sh -c and incorrect sh -s from affected templates and Ruby installers. The raw summary lists direct-command changes in the TypeScript, Stylelint, gopls, Harper, Perl, SysML, EO, rust-analyzer, wgsl-analyzer, Ruby LSP (template and installer), Ruby Debug installer, and HTML templates. Windows commands are unchanged.
(2) Update the template documentation example and explain the environment and shell usage. docs/UserDefinedLanguageServer.md and docs/UserDefinedLanguageServerTemplate.md are updated, as are the gopls and rust-analyzer pages.
(3) Use CommandUtils.createCommands for installer string commands. The ExecTaskFactory diff confirms fillCommand now calls CommandUtils.createCommands(command.getAsString()) in place of split(" ").
(4) Ruby LSP install-check timeout is explicitly out of scope and tracked in #1957. The PR does not change it.
Automated tests: BundledTemplateCommandsTest and ExecTaskFactoryTest are added. The author reports they pass. I did not run them; the pass result relies on the diff and the reported run.

Full details: Out of Scope Changes check

Explanation

All changed files relate to #1954 or to the jq-lsp fix that the PR description states (#1956). The jq-lsp installer diff changes the command from jq-lsp -mode=stdio to jq-lsp and corrects the failure message to name jq-lsp. This is a small, connected change. #1956 is not in the linked issue list, but the PR description and the PR objectives both state it as in scope. The test changes support the template and installer changes. The ExecTaskFactory getCommand visibility change supports the new unit test. The installer timeout check (#1957) is not changed, so no out-of-scope change of that kind appears.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 462d8f11-93a8-4a63-ba9f-8dab0d7cb0c1
Commits

Reviewing files that changed from the base of the PR and between 9d4537a and dbac0b5.

Files selected for processing: 21

  • docs/UserDefinedLanguageServer.md
  • docs/UserDefinedLanguageServerTemplate.md
  • docs/user-defined-ls/gopls.md
  • docs/user-defined-ls/rust-analyzer.md
  • src/main/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/ExecTaskFactory.java
  • src/main/resources/templates/dap/ruby-rdbg/installer.json
  • src/main/resources/templates/lsp/eo-lsp-server/template.json
  • src/main/resources/templates/lsp/gopls/template.json
  • src/main/resources/templates/lsp/harper-ls/template.json
  • src/main/resources/templates/lsp/jq-lsp/installer.json
  • src/main/resources/templates/lsp/perl-lsp/template.json
  • src/main/resources/templates/lsp/ruby-lsp/installer.json
  • src/main/resources/templates/lsp/ruby-lsp/template.json
  • src/main/resources/templates/lsp/rust-analyzer/template.json
  • src/main/resources/templates/lsp/stylelint-lsp/template.json
  • src/main/resources/templates/lsp/sysml-lsp/template.json
  • src/main/resources/templates/lsp/typescript-language-server/template.json
  • src/main/resources/templates/lsp/vscode-html-language-server/template.json
  • src/main/resources/templates/lsp/wgsl-analyzer/template.json
  • src/test/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/ExecTaskFactoryTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/launching/templates/BundledTemplateCommandsTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.38%. Comparing base (9d4537a) to head (dbac0b5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1976      +/-   ##
==========================================
+ Coverage   48.35%   48.38%   +0.03%     
==========================================
  Files         809      809              
  Lines       32556    32555       -1     
  Branches     6637     6637              
==========================================
+ Hits        15741    15752      +11     
+ Misses      14309    14300       -9     
+ Partials     2506     2503       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit da4b1d6 into redhat-developer:main Nov 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Templates: sh -c drops arguments, and sh -s breaks Ruby

1 participant