Skip to content

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

Closed

Description

@muescha

Found while testing #1870, though not caused by it; collected in #1943.

Summary

Several templates start their language server with sh -c <command> <argument>, for example the TypeScript template's sh -c typescript-language-server --stdio. LSP4IJ splits the command at spaces, so sh gets -c, typescript-language-server and --stdio as separate arguments. sh -c only runs the first one; the rest become $0, $1, … of that command, so the language server starts without --stdio:

$ sh -c 'echo "$0=$0 args=[$*]"' --stdio
$0=--stdio args=[]

It mostly goes unnoticed, as the installers of these templates replace the command ("update": true) the first time a file opens. Until then, or without the installer, the command is broken.

The Ruby LSP installer has the same problem: sh -c gem install ruby-lsp only runs gem, which prints its help and exits with 1. Quoting doesn't help there, since ExecTaskFactory splits a string command with split(" "), without regard to quotes.

The two Ruby templates are worse off: they use sh -s instead of sh -c. With -s, sh reads its commands from stdin, so the Ruby LSP template never starts ruby-lsp and feeds the LSP messages to sh instead, and the Ruby Debug installer waits for commands on stdin instead of installing (see below).

Affected

  • typescript-language-server, stylelint-lsp, gopls, harper-ls, perl-lsp, sysml-lsp, eo-lsp-server: template.json, programArgs.default
  • ruby-lsp: installer.json, run.exec.command.default
  • ruby-lsp: template.json, programArgs.default is sh -s ruby-lsp, which is worse, see below
  • ruby-rdbg (debug adapter): installer.json, run.exec.command.default is sh -s gem install debug, see below
  • gopls loses -mode=stdio, but talks over stdio without it too.
  • rust-analyzer and wgsl-analyzer use the same form, but without arguments, so nothing is lost there.
  • vscode-html-language-server quotes it right (sh -c "node '…' --stdio"), so it works, but doesn't need sh -c either.
  • The first example in the template docs shows the same sh -c typescript-language-server --stdio, copied from the TypeScript template in #1934, so it needs the same fix.

The TypeScript template had sh -c \"typescript-language-server --stdio\" with quotes until 335daf8 ("Exec task improve", #1082, June 2025); the others took the form over later. Was there a reason to drop the quotes, maybe the installer splitting strings only at spaces (see below)?

sh -s in the Ruby templates

With -s, sh reads its commands from stdin, and the other arguments only become $1, $2, …:

$ echo 'echo "ran from stdin, $1=$1"' | sh -s ruby-lsp
ran from stdin, $1=ruby-lsp
$ printf 'Content-Length: 52\r\n\r\n{"jsonrpc":"2.0","id":0,"method":"initialize"}' | sh -s ruby-lsp
sh: line 1: Content-Length:: command not found
sh: line 2: : command not found
sh: line 3: jsonrpc:2.0: command not found
  • The Ruby LSP template starts sh -s ruby-lsp: ruby-lsp never runs, and sh takes the LSP messages on stdin for shell code.
  • The Ruby Debug installer runs sh -s gem install debug: sh waits for commands on stdin. ExecTask runs it with a CapturingProcessHandler and no timeout, and doesn't close stdin, so it likely waits until it's cancelled. With an empty stdin, it would exit with 0 without installing anything.
  • The Ruby LSP installer's check runs the start command, sh -s ruby-lsp, with a 2 s timeout, and ExecTask counts a timeout as success, so the check passes although nothing is installed, and Install if Needed never installs it (see the next section and Installer check: a hanging command counts as installed #1957).

Both came with f6c7ea63 ("feat: add ruby-lsp") and 335daf8; -s was likely meant to be -c. Without a shell, ruby-lsp and gem install debug would do.

The installer check counts a timeout as success

The Ruby LSP check only passes because ExecTask counts a command that is still running after its 2 s timeout as success, and Install if Needed then skips the install. That affects 20 installers, not only Ruby, and is about the installer code rather than the templates, so it's #1957 now, with ideas for a reliable check.

Is sh -c needed?

I don't think so. sh -c is a non-interactive, non-login shell: it reads no configuration (no .zprofile, .zshrc or .bash_profile) and only passes on the PATH it gets. That PATH comes from LSP4IJ: createCommandLine and ExecTask pass EnvironmentUtil.getEnvironmentMap(): the environment IntelliJ loads from the user's login shell when it starts from the Dock or Finder, or the terminal's when it starts from one. GeneralCommandLine looks the command up on that same PATH, so typescript-language-server --stdio finds the same program as sh -c "typescript-language-server --stdio". With a working directory, LSP4IJ looks the command up in the PATH of that directory's environment, e.g. from mise or direnv, as the user guide describes since #1693 and #1894; sh -c doesn't change that either.

The habit may come from the user guide itself, which says: "Depending on your OS, the environment variables may not be accessible. To make sure they are accessible", use cmd /c command_to_start_your_ls on Windows and sh -c command_to_start_your_ls on Linux and macOS. As above, sh -c doesn't load any environment of its own; it only passes on what it gets.

On macOS, /bin/sh is bash 3.2 in POSIX mode, and it keeps the PATH it's given:

$ env -i PATH=/usr/bin:/bin /bin/sh -c 'echo $PATH'
/usr/bin:/bin
$ env -i PATH=/usr/bin:/bin HOME=$HOME /bin/zsh -lc 'echo $PATH'
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:…:/usr/bin:/bin:…

sh -c would only matter for shell syntax (&&, pipes, ~, globs), which none of these commands use (${BASE_DIR} and ${workingDir} are resolved by LSP4IJ itself). A login shell ($SHELL -l -c) would read .zprofile again, which the IDE already did, and an interactive one can print to stdout on start, which breaks a server talking over stdio.

Suggested fix

  • Change the user guide's advice to use sh -c or cmd /c for the environment variables: say where the environment comes from (EnvironmentUtil, the directory's environment, the variables configured in the settings), and use a shell only for shell syntax, with the whole command quoted.
  • Drop sh -c and sh -s from these commands, e.g. "default": "typescript-language-server --stdio", "default": "ruby-lsp", "default": "gem install ruby-lsp" and "default": "gem install debug". Then they look like the other templates, and the mistake can't come back. Change the example in the template docs the same way.
  • Quoting, as the HTML template does, would work in template.json, but not for a string in installer.json (see above), and leaves the trap open for the next template, so I'd rather not.
  • Split string commands in ExecTaskFactory with CommandUtils.createCommands too, so templates and installers split the same way.
  • If a template ever needs shell syntax, a flag such as "shell": true could let LSP4IJ wrap the whole command as ["/bin/sh", "-c", command] (or cmd /C on Windows), so nobody has to get the quoting right by hand.

Other findings in the templates

Besides sh -c and sh -s, the inventory below shows a few things that might be issues of their own:

Inventory of all templates

All start and install commands at main 42b4e25d (2026-11-09), with the problems found. The installer check ${server.command} runs the start command. Where a template has commands per system, others is its default.

Language servers (33)

ada_language_server

  • Files on main: template.json, installer.json
  • Start:
    • Windows: "${BASE_DIR}/ada_language_server.exe"
    • others: "${BASE_DIR}/ada_language_server"
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name}

astro-ls

  • Problem: On Windows, the start command runs astro-ls.cmd directly, while the TypeScript, Stylelint, EO and Candor templates wrap their .cmd in cmd /C. The templates disagree on whether a .cmd needs it; which is right hasn't been tried on Windows.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: astro-ls.cmd --stdio
    • others: astro-ls --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install @astrojs/language-server prettier-plugin-astro typescript --force
    • others: npm install @astrojs/language-server prettier-plugin-astro typescript --force
  • Command after install:
    • Windows: ${workingDir}/.bin/astro-ls.cmd --stdio
    • others: ${workingDir}/.bin/astro-ls --stdio

camel-lsp-server

  • Problem: The start command java -jar camel-lsp-server-XXX.jar has the placeholder XXX for the version, so it can't work before the installer has run. The installer finds the latest version on Maven Central itself. See Templates: placeholders in commands aren't recognized #1959.
  • Files on main: template.json, installer.json
  • Start: java -jar camel-lsp-server-XXX.jar
  • Install: downloads the server
  • Command after install: java -jar ${output.dir}/${output.file.name}

candor-lsp

  • Files on main: template.json, installer.json
  • Start:
    • Windows: cmd /C candor-lsp.cmd
    • others: candor-lsp
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install candor-ts --force
    • others: npm install candor-ts --force
  • Command after install:
    • Windows: ${workingDir}/.bin/candor-lsp.cmd
    • others: ${workingDir}/.bin/candor-lsp

clangd

clojure-lsp

  • Files on main: template.json, installer.json
  • Start:
    • Windows: "${BASE_DIR}/clojure-lsp.exe"
    • others: "${BASE_DIR}/clojure-lsp.sh"
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name}

dart-lsp

  • Files on main: template.json, installer.json
  • Start: dart language-server
  • Installer check: ${server.command}
  • Command after install: dart language-server

docker-language-server

  • Files on main: template.json, installer.json
  • Start: docker-language-server start --stdio
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name} start --stdio

eo-lsp-server

  • Problem: The start command sh -c eo-lsp-server --stdio is split at spaces, so sh -c only runs eo-lsp-server, and --stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: cmd /C eo-lsp-server.cmd --stdio
    • others: sh -c eo-lsp-server --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install eo-lsp-server --force
    • others: npm install eo-lsp-server --force
  • Command after install:
    • Windows: ${workingDir}/.bin/eo-lsp-server.cmd --stdio
    • others: ${workingDir}/.bin/eo-lsp-server --stdio

erlang-ls

gopls

  • Problem: The start command sh -c gopls -mode=stdio is split at spaces, so sh -c only runs gopls, and -mode=stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it. gopls talks over stdio without it too, so it still works.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: gopls -mode=stdio
    • others: sh -c gopls -mode=stdio
  • Installer check: ${server.command}
  • Install: go install golang.org/x/tools/gopls@latest
  • Command after install: gopls -mode=stdio

harper-ls

  • Problem: The start command sh -c ${BASE_DIR}/harper-ls --stdio is split at spaces, so sh -c only runs ${BASE_DIR}/harper-ls, and --stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: ${BASE_DIR}/harper-ls.exe --stdio
    • others: sh -c ${BASE_DIR}/harper-ls --stdio
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name} --stdio

jdtls

jq-lsp

julia

  • Note: The debug adapter for Julia has the same id, julia.
  • Files on main: template.json
  • Start: julia -e "using LanguageServer; runserver()"
  • No installer

lemminx

  • Note: "runtime": "java": LSP4IJ adds the Java runtime, so the command only holds the Java arguments.
  • Files on main: template.json
  • Start: -classpath "${BASE_DIR}/org.eclipse.lemminx-uber.jar" org.eclipse.lemminx.XMLServerLauncher
  • No installer

luau-lsp

metals

  • Files on main: template.json, installer.json
  • Start:
    • Windows: "$USER_HOME$/.lsp4ij/lsp/metals/metals.bat"
    • others: "$USER_HOME$/.lsp4ij/lsp/metals/metals"
  • Installer check: ${server.command}
  • Install: cs install metals --install-dir .
  • Command after install:
    • Windows: ${workingDir}/metals.bat
    • others: ${workingDir}/metals

perl-lsp

  • Problem: The start command sh -c ${BASE_DIR}/perllsp --stdio is split at spaces, so sh -c only runs ${BASE_DIR}/perllsp, and --stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: ${BASE_DIR}/perllsp.exe --stdio
    • others: sh -c ${BASE_DIR}/perllsp --stdio
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name} --stdio

ruby-lsp

  • Problem: The start command is sh -s ruby-lsp. With -s, sh reads its commands from stdin, i.e. the LSP messages, so ruby-lsp never runs.
  • Problem: The installer check runs that command; it hangs until the 2 s timeout, which counts as success, so Install if Needed doesn't install anything. See Installer check: a hanging command counts as installed #1957.
  • Problem: The install runs sh -c gem install ruby-lsp, which only runs gem (it prints its help and exits with 1).
  • Files on main: template.json, installer.json
  • Start:
    • Windows: cmd /C ruby-lsp
    • others: sh -s ruby-lsp
  • Installer check: ${server.command}
  • Install:
    • Windows: cmd /C gem install ruby-lsp
    • others: sh -c gem install ruby-lsp

rust-analyzer

  • Problem: The start command wraps ${BASE_DIR}/rust-analyzer in sh -c. Without arguments nothing is lost, but sh -c isn't needed: the program is found without a shell.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: ${BASE_DIR}/rust-analyzer.exe
    • others: sh -c ${BASE_DIR}/rust-analyzer
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name}

sdl-lsp

sourcekit-lsp

  • Files on main: template.json, installer.json
  • Start: sourcekit-lsp
  • Installer check: ${server.command}
  • Command after install: sourcekit-lsp

stylelint-lsp

  • Problem: The start command sh -c stylelint-lsp --stdio is split at spaces, so sh -c only runs stylelint-lsp, and --stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: cmd /C stylelint-lsp.cmd --stdio
    • others: sh -c stylelint-lsp --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install stylelint-lsp --force
    • others: npm install stylelint-lsp --force
  • Command after install:
    • Windows: ${workingDir}/.bin/stylelint-lsp.cmd --stdio
    • others: ${workingDir}/.bin/stylelint-lsp --stdio

svelte-language-server

  • Problem: On Windows, the start command runs svelteserver.cmd directly, while the TypeScript, Stylelint, EO and Candor templates wrap their .cmd in cmd /C. The templates disagree on whether a .cmd needs it; which is right hasn't been tried on Windows.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: svelteserver.cmd --stdio
    • others: svelteserver --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install svelte-language-server --force
    • others: npm install svelte-language-server --force
  • Command after install:
    • Windows: ${workingDir}/.bin/svelteserver.cmd --stdio
    • others: ${workingDir}/.bin/svelteserver --stdio

sysml-lsp

  • Problem: The start command sh -c sysml-lsp --stdio is split at spaces, so sh -c only runs sysml-lsp, and --stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: sysml-lsp --stdio
    • others: sh -c sysml-lsp --stdio
  • Installer check: ${server.command}
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name} --stdio

terraform-ls

typescript-language-server

  • Problem: The start command sh -c typescript-language-server --stdio is split at spaces, so sh -c only runs typescript-language-server, and --stdio becomes $0 instead of reaching the server. The installer replaces the command with one without sh -c, so this only shows before the installer has run, or without it.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: cmd /C typescript-language-server.cmd --stdio
    • others: sh -c typescript-language-server --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install typescript-language-server typescript --force
    • others: npm install typescript-language-server typescript --force
  • Command after install:
    • Windows: ${workingDir}/.bin/typescript-language-server.cmd --stdio
    • others: ${workingDir}/.bin/typescript-language-server --stdio

vscode-css-language-server

  • Problem: It installs the whole vscode-langservers-extracted package into its own folder, and the ESLint template does the same, so it's there twice. See Templates: install folders and commands don't always match #1960.
  • Files on main: template.json, installer.json
  • Start: node $USER_HOME$/.lsp4ij/lsp/vscode-css-language-server/node_modules/vscode-langservers-extracted/lib/css-language-server/node/cssServerMain.js --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install vscode-langservers-extracted --force
    • others: npm install vscode-langservers-extracted --force
  • Command after install: node ${workingDir}/vscode-langservers-extracted/lib/css-language-server/node/cssServerMain.js --stdio

vscode-eslint-language-server

  • Problem: It installs the whole vscode-langservers-extracted package into its own folder, and the CSS template does the same, so it's there twice. See Templates: install folders and commands don't always match #1960.
  • Files on main: template.json, installer.json
  • Start: node $USER_HOME$/.lsp4ij/lsp/vscode-eslint-language-server/node_modules/vscode-langservers-extracted/lib/eslint-language-server/eslintServer.js --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install vscode-langservers-extracted --force
    • others: npm install vscode-langservers-extracted --force
  • Command after install: node ${workingDir}/vscode-langservers-extracted/lib/eslint-language-server/eslintServer.js --stdio

vscode-html-language-server

  • Problem: On macOS and Linux, the start command is sh -c "node '…' --stdio". It's quoted right and works, but sh -c isn't needed: node is found on the PATH without a shell.
  • Problem: There's no installer; the command points to the HTML server inside a VS Code installation, although the vscode-langservers-extracted package that the CSS and ESLint templates install has it too. See Templates: install folders and commands don't always match #1960.
  • Files on main: template.json
  • Start:
    • Windows: node "$USER_HOME$/AppData/Local/Programs/Microsoft VS Code/resources/app/extensions/html-language-features/server/dist/node/htmlServerMain.js" --stdio
    • macOS: sh -c "node '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html-language-features/server/dist/node/htmlServerMain.js' --stdio"
    • Linux: sh -c "node '/usr/share/code/resources/app/extensions/html-language-features/server/dist/node/htmlServerMain.js' --stdio"
    • others: sh -c "node 'resources/app/extensions/html-language-features/server/dist/node/htmlServerMain.js' --stdio"
  • No installer

vue-js-language-server

  • Problem: On Windows, the start command runs vue-language-server.cmd directly, while the TypeScript, Stylelint, EO and Candor templates wrap their .cmd in cmd /C. The templates disagree on whether a .cmd needs it; which is right hasn't been tried on Windows.
  • Problem: It installs into ~/.lsp4ij/lsp/vue-js-language-server-ls, with an extra -ls, and without the node_modules the other npm installers have in their workingDir. See Templates: install folders and commands don't always match #1960.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: vue-language-server.cmd --stdio
    • others: vue-language-server --stdio
  • Installer check: ${server.command}
  • Install:
    • Windows: npm.cmd install @vue/language-server typescript --force
    • others: npm install @vue/language-server typescript --force
  • Command after install:
    • Windows: ${workingDir}/node_modules/.bin/vue-language-server.cmd --stdio
    • others: ${workingDir}/node_modules/.bin/vue-language-server --stdio

wgsl-analyzer

  • Problem: The start command wraps ${BASE_DIR}/wgsl-analyzer in sh -c. Without arguments nothing is lost, but sh -c isn't needed: the program is found without a shell.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: ${BASE_DIR}/wgsl-analyzer.exe
    • others: sh -c ${BASE_DIR}/wgsl-analyzer
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name}

Debug adapters (9)

buildx-dockerfile

  • Files on main: template.json
  • Start:
    • Windows: docker.exe buildx dap build
    • others: docker buildx dap build
  • No installer

codelldb

  • Problem: The start command has the placeholder <<insert base directory>>. The installer replaces it with its folder, but without the installer the command can't work. See Templates: placeholders in commands aren't recognized #1959.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: <<insert base directory>>/extension/adapter/codelldb.exe
    • others: <<insert base directory>>/extension/adapter/codelldb
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name}

go-delve

  • Files on main: template.json, installer.json
  • Start: dlv dap
  • Installer check: ${server.command}
  • Install: go install github.com/go-delve/delve/cmd/dlv@latest
  • Command after install: dlv dap

julia

  • Note: The language server for Julia has the same id, julia.
  • Files on main: template.json
  • Start: julia $PROJECT_DIR$/server.jl ${port}
  • No installer

perl-dap

  • Problem: The start command has the placeholder <<insert base directory>>. The installer replaces it with its folder, but without the installer the command can't work. See Templates: placeholders in commands aren't recognized #1959.
  • Problem: It installs into ~/.lsp4ij/dap/perl-lsp, named after the archive, not into ~/.lsp4ij/dap/perl-dap after its template id as the other installers do. It downloads the same archive as the perl-lsp template, so it's downloaded twice, but it doesn't overwrite it (dap/ and lsp/ are separate). See Templates: install folders and commands don't always match #1960.
  • Files on main: template.json, installer.json
  • Start:
    • Windows: <<insert base directory>>/perl-dap.exe
    • others: <<insert base directory>>/perl-dap
  • Install: downloads the server
  • Command after install: ${output.dir}/${output.file.name}

python-debugpy

ruby-rdbg

  • Problem: The install runs sh -s gem install debug. With -s, sh reads its commands from stdin; ExecTask doesn't close stdin and has no timeout for it, so it likely waits until it's cancelled instead of installing.
  • Files on main: template.json, installer.json
  • Start: set by the user
  • Installer check: ${server.command}
  • Install:
    • Windows: cmd /C gem install debug
    • others: sh -s gem install debug

swift-lldb

vscode-js-debug

  • Problem: The start command has the placeholder <<insert base directory>>. The installer replaces it with its folder, but without the installer the command can't work. See Templates: placeholders in commands aren't recognized #1959.
  • Files on main: template.json, installer.json
  • Start: node <<insert base directory>>/js-debug/src/dapDebugServer.js ${port} 127.0.0.1
  • Install: downloads the server
  • Command after install: node ${output.dir}/src/dapDebugServer.js ${port} 127.0.0.1

How this was checked

Tried: only how sh -c, sh -s and zsh -lc behave, on macOS. The inventory was made by Claude Code from the template files at 42b4e25; the jq-lsp option check comes from its source, not from running it. None of the affected servers was started without its installer. That the Ruby LSP installer installs nothing comes from the code and from running sh -c gem install ruby-lsp by hand (exit 1, only gem's help); the installer itself wasn't run in the IDE. That IntelliJ loads the login shell's environment when started from the Dock or Finder (EnvironmentUtil) is known IntelliJ behaviour, only seen indirectly here: the runIde sandbox logs "loading shell env is skipped: IDE has been launched from a terminal". Windows wasn't looked at: there the templates use cmd /C ….cmd, for other reasons (Java doesn't find .cmd files through PATHEXT).

Activity

  1. muescha commented on Nov 11, 2026

    @muescha
    ContributorAuthor

    A note before anyone picks this up: the section "Is sh -c needed?" needs a decision from the maintainers first, since it decides what the fix looks like.

    Options:

    1. Drop the shell (what the issue suggests): plain commands such as typescript-language-server --stdio, ruby-lsp and gem install debug in the templates and the docs example, and the user guide no longer advises sh -c / cmd /c for the environment variables.
    2. Keep sh -c, but quote the whole command, as before 335daf8 (Exec task improve #1082). That works in template.json, but in installer.json only once ExecTaskFactory splits with quotes in mind, and each new template has to get the quoting right again.
    3. Option 1, plus a "shell": true flag for a template that really needs shell syntax, so LSP4IJ wraps the command itself (sh -c or cmd /C).

    Open question: was there a reason to drop the quotes in 335daf8, for example the installer splitting strings only at spaces? If so, that reason would favour option 1 or 3.

    Not affected by the decision, so these could go ahead right away:

    • The Ruby templates: sh -s is wrong either way (sh -s ruby-lsp never starts ruby-lsp).
    • ExecTaskFactory splitting string commands with CommandUtils.createCommands, so templates and installers split the same way.
  2. muescha commented on Nov 11, 2026

    @muescha
    ContributorAuthor

    More input for the decision, from a look at the code on main (b80ec21e) by Claude Code: what happens to servers created before the fix, how a "shell" field could handle old templates and settings, and an option 4.

    Servers created before the fix

    A plugin update with fixed templates doesn't change servers that already exist. LSP4IJ doesn't ignore their settings, but it doesn't take anything from the new templates either. When a server is created from a template, LSP4IJ copies the command (commandLine) and the installer JSON (installerConfigurationContent) into the settings and starts the server from that copy from then on. Of the template, only templateId is kept, and it's read in two places only:

    So a server created with sh -c typescript-language-server --stdio keeps that command until the installer ("update": true) or the user replaces it, and a Ruby LSP server with sh -s ruby-lsp stays broken.

    Where old commands live:

    Where Is the template read again later? What it needs
    Bundled templates (src/main/resources/templates/lsp, …/dap) yes, for each new server fixed in the same release; no compatibility issue
    Custom templates (folder or ZIP, Import from custom template), including old exports yes, when a server is created they have no "shell", so "as today"
    Servers created already (UserDefinedLanguageServerItemSettings) no: commandLine and installerConfigurationContent are copies, only templateId is kept a "shell" field has to go into the settings too, or these always run "as today"
    Command set by the installer (configureServer with "update": true, ConfigureServerTask → setCommandLine) – ends up in commandLine of the settings, without a field
    Debug adapters (DAPTemplateDeserializer, DAP settings) same as above the same again

    The servers created already are the ones affected most. Ways to deal with them, whichever option is chosen:

    • Migrate once on load: if templateId names a bundled template and the saved command is exactly that template's old, broken command, replace it with the new one. A command the user changed doesn't match, so it's left alone. This needs a list "old command → new command" per template, for this one release.
    • Warn: flag sh -c followed by more than one unquoted word, and sh -s, in the settings and on a failed start. Rewriting such commands without an exact match isn't safe: sh -c script a b with $0/$1 is valid shell and may be intended.
    • Do nothing: users delete and recreate the server, as with every template change today.

    A "shell" field: "set → new rules, missing → as today"

    One way to keep old templates and settings working: if a template has "shell": true or "shell": false, the new rules apply; without the field, the old ones.

    LSP4IJ never wraps a command in a shell today, so "as today" already means "no shell, the command as written". "shell": false would do exactly the same, so for starting the server, a missing field and false are the same; only true changes something (["/bin/sh", "-c", command], or ["cmd", "/C", command] on Windows).

    The rule matters where the old behaviour should change without breaking old templates:

    1. Splitting installer commands. ExecTaskFactory splits a string command with split(" "), without regard to quotes. With the field: CommandUtils.createCommands, which respects "…", as when the server starts. Without it: split(" ") as before, so an old installer with " in a command behaves the same.
    2. Warning on sh -c a b c. Without the field, LSP4IJ could flag more than one unquoted word after sh -c. With the field, it takes the command literally.

    Things to watch:

    • The settings need a third state. A Boolean shell in UserDefinedLanguageServerItemSettings, with null for "as today". The pattern exists already: transportMode defaults to stdio for settings saved without one, "as they did". The New Language Server dialog takes the field from the template, and LanguageServerDefinitionSerializer writes it on export only when it's set.
    • The UI has to show it. Otherwise someone who edits the command in the settings can't see whether it runs in a shell. Either a "Run in a shell" checkbox with three states, or two states, where "as today" becomes false on the first save.
    • Installer commands. The field also belongs on run.exec / check.exec in installer.json, not only on programArgs. The installer JSON is kept as a copy in the settings, so a field in the JSON is enough there.
    • Two meanings in one field. "shell" would be both a switch ("start in a shell") and a version marker ("new splitting rules"). That works, but it needs to be documented; otherwise it's a surprise that "shell": false changes how the installer splits.

    So the rule fits and breaks nothing: anything without the field behaves as today. The bundled templates don't need the field, only the fixed command. For servers created already, the field alone doesn't help; the broken sh -c commands stay broken until someone changes them. A warning makes them visible, with or without the field.

    If no bundled template needs shell syntax after the fix, the field can wait (option 1). Then the fixed templates, the warning and createCommands in the installer are enough. For the installer splitting, "missing → split(" ")" no longer applies then; instead, check whether an existing installer has " in a string command. Among the bundled ones, only jdtls has "…", in configureServer, and that goes through createCommands, not through ExecTaskFactory.

    Option 4: always run the command in a shell

    LSP4IJ would start every command as ["/bin/sh", "-c", command], or ["cmd", "/C", command] on Windows, without a field.

    Option 1 + "shell": true (opt-in) Option 4 (always a shell)
    Existing servers after the update run as before (no field → no shell) all run differently: every command now goes through sh/cmd
    Old sh -c a b stay broken (migration or warning needed) stay broken: sh -c "sh -c a b" loses the same arguments inside
    Shell syntax (&&, ~, $HOME, globs) only with the field always
    Quotes CommandUtils, as today sh parses them, plus $, ` and \ inside "…"; on Windows the rules of cmd /C (%VAR%, ^, &, quotes at start and end)
    Substituted values ($PROJECT_DIR$, ${workingDir}, ${output.dir}, paths) passed as arguments, no risk end up in the shell text: a folder name with $(…), ; or & would run; LSP4IJ would have to escape every value, for sh and for cmd
    Installer with an array command (["npm", "install", "-g", …]) unchanged has to be joined into a string and escaped
    Process the server itself macOS's /bin/sh (bash 3.2) replaces itself with a single simple command (exec, checked); for a; b or a && b, sh stays the parent. cmd /C always stays the parent: stopping may end only cmd.exe and leave the server running on Windows
    PID in the LSP console, error message the server's PID; "Cannot run program …" maybe the shell's PID; a missing program becomes exit code 127 with sh: …: command not found instead of a start error
    PATH the same the same: sh gets the same environment, including the working directory's (WorkingDirectoryCommandLine then looks up sh, and sh looks up the server in that environment)

    Option 4 only prevents getting the quoting of sh -c wrong. In return, every existing server behaves differently, substituted values become shell code, and Windows gets orphaned processes and other quoting rules. To spare existing settings, option 4 would need the same "no field → no shell" rule, and then it's option 3 with a different default for new templates.

    Suggestion

    Option 1: plain commands in the templates, a warning (or the one-time migration) for existing servers, and CommandUtils.createCommands in ExecTaskFactory. Add a "shell": true field only once a template needs shell syntax.

    The Windows points (cmd /C as parent, quoting) aren't tested; they come from how cmd /C works. The /bin/sh exec behaviour was checked on macOS.

  3. added this to the 0.30.0 milestone on Nov 11, 2026
  4. added a commit that references this issue on Nov 12, 2026
    da4b1d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions