Repository navigation
Find and run the language server and the CLI everywhere, Flatpak included - #33
Merged
Merged
Conversation
added 9 commits
November 16, 2026 01:50
…uded path mode looked the bare name up with fs.existsSync, which checks the current directory, so it never found anything (#29). The name is now resolved against PATH (PATHEXT on Windows), and the error lists the directories searched. The CLI resolves the same way. A host mode for comline.server.mode and comline.cli.mode runs the program on the host through flatpak-spawn --host, with stdio piped and RUST_LOG passed as --env. Inside a Flatpak, path mode does this on its own, since the sandbox's PATH is not the host's. flatpak-spawn and the program on the host are checked first, and the message says what to install or which setting to change. Generate and Clean run comline generation and comline generation clean, as cli#153 renamed them (#30). The command ids are unchanged. The CLI commands are registered before the server is looked up, so a missing server no longer takes them away. The resolution is in src/resolve.ts, free of vscode, with unit tests run by yarn test in the Package Test job.
A workflow that installs com.vscodium.codium from Flathub on an Ubuntu VM and runs out/resolve.js inside it, with a real flatpak-spawn --host: the bundled server in the sandbox, host mode (by name, by a path in the host's /usr, by a path in the home directory, RUST_LOG, --watch-bus), the host probe, path and custom resolution, and the CLI's generation and generation clean on disk. The system probe and the host check move into resolve.ts so the extension and the test run the same code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #29. Closes #30.
What changed
Resolution (
src/resolve.ts, new). Pure code with novscodeimport: PATH lookup, Flatpak detection, the plan for each mode, and the command line.extension.tssupplies the real file system and runs the result.path(server and CLI): the name is looked up onprocess.env.PATH, withPATHEXTon Windows (Server mode "path" never finds comline-lsp: existsSync checks the cwd, not PATH #29). The old check wasfs.existsSync('comline-lsp'), which reads the cwd. The error lists the directories searched. Acustompath with no directory in it is looked up the same way.host(new value ofcomline.server.modeandcomline.cli.mode): runs the program throughflatpak-spawn --host. The server keeps stdio piped (Executablewithcommand: flatpak-spawn,args: ["--host", "--watch-bus", "--env=RUST_LOG=debug", "comline-lsp"]).--env=carriesRUST_LOG, since the host command doesn't get the sandbox's environment.--watch-busends the host process withflatpak-spawn, so the server doesn't outlive the editor. The CLI task passesCLICOLOR_FORCEthe same way.comline.server.customPath/comline.cli.customPathname the program to run inhostmode when set (an absolute host path, for a binary on no PATH the host session has, e.g.~/.cargo/bin). Outside a Flatpak,hostis the same aspath/custom, so a synced settings file works on every machine.flatpak-spawn, the extension checks thatflatpak-spawnexists in the sandbox and asks the host's shell (command -v) whether the program is there. It then reports one of: what to install and which setting to change; or thatflatpak-spawn --hostitself failed (stderr passed on, with the--talk-name=org.freedesktop.Flatpakoverride to grant).sh -c 'command -v "$1"', never spliced into the script.Default inside a Flatpak.
comline.server.modestaysbundled;comline.cli.modestayspath. Inside a Flatpak,pathnow means the host, for both.flatpak-spawn, no D-Bus permission, and nothing installed on the host. Makinghostthe default would turn a working default into one that can fail.comline, so for the CLIpathcould only ever fail in a Flatpak. Mapping it to the host makes the default work and needs no new setting.custominside a Flatpak is run as written in the sandbox, as before. If the file isn't there, the message says why (the host's/usretc. are reserved) and to usehost.config.get, and keying on it would make behaviour depend on whether the user ever saved the value.CLI commands (#30). Generate runs
comline generationand Clean runscomline generation clean. I checked ComlineProject/climain(src/cli.rs,docs/cli.md):Generation(visible aliasgen) has the subcommandClean; the top-levelGenerate/Cleanare gone;Targetsis unchanged, so the code-generation target completion keeps working. I used the full namegenerationover the alias. Command ids (comline.generate,comline.clean) and titles are unchanged, so keybindings keep working. These commands now need a CLI with cli#153. The status bar menu uses the same subcommands.Also fixed. Build/Check/Generate/Clean/Select Package were registered after the server lookup, so a server that wasn't found removed them (command not found). They're registered first now.
Docs.
package.json:hostin both enums, with descriptions;customPathdescriptions say what they do inhostmode. README: the Flatpak workaround section is now the short version (automatic, or one setting), with the custom-path and/usrcaveat kept. CHANGELOG: Unreleased entries.Tests. There was no test setup.
yarn test(node --test, Node's built-in runner, no new dependency) runssrc/resolve.test.tsafteryarn compile: PATH lookup (order, empty entries, cwd not searched, a path as written, WindowsPath/PATHEXT), Flatpak detection, each mode's plan inside and outside a Flatpak, command and argument construction (stdio,--env,--watch-bus), host probe results, and the messages. It's a step of the Package Test job..vscodeignorekeepsout/**/*.test.jsout of the.vsix.Flatpak references
flatpak-spawn --host: "Run the command unsandboxed on the host. This requires access to the org.freedesktop.Flatpak D-Bus interface." Also--env=VAR=VALUE,--watch-bus,--directory(flatpak-spawn, source).FLATPAK_IDis set to the app's id in the sandbox (flatpak run, Environment);/.flatpak-infois the instance's metadata (flatpak metadata). Either marks a Flatpak.--filesystem=hostmounts the host's/usr,/bin,/sbin,/lib*(host-os) at/run/host, not at/usr;/usr,/etc,/bin,/lib,/run/hostand others are reserved and a--filesystemfor them has no effect (sandbox permissions, "Reserved Paths").master, have--filesystem=hostand--talk-name=org.freedesktop.Flatpak: com.vscodium.codium, com.visualstudio.code. They don't differ on these. The VS Code one also bundleshost-spawn(a separate tool the extension doesn't use) and adds--talk-name=org.freedesktop.Notifications.Flatpak end-to-end (
.github/workflows/flatpak.yml)Runs the extension's real resolution (
out/resolve.js, withsystemProbe(): the real file system and environment) inside Flathub's realcom.vscodium.codiumsandbox, headless (flatpak run --command=/app/share/codium/com.vscodium.codium --env=ELECTRON_RUN_AS_NODE=1), underdbus-run-session, against a realflatpak-spawn --host.scripts/flatpak-e2e.cjshas the scenarios; each is an assertion that fails the job:comline-lspruns in the sandbox and answersinitializeover stdio.comline-lspruns on the host (by name; by an absolute path in the host-only/usr/local/bin; by an absolute path in the home directory) and answersinitialize. With debug on,RUST_LOG=debugis in the host process's/proc/<pid>/environ, and absent without it. The host process'sexeis the host binary. A clean stop ends it; killingflatpak-spawnends it.comline-lspalso exits when its stdin closes, so that alone doesn't prove--watch-bus. Scenario 2d usessleepon the host, which ignores stdin: with--watch-busit ends whenflatpak-spawnis killed, and the control without it keeps running.okwhen present,missingwhen not,failed(with the reason) whenflatpak-spawncan't reach the session bus; and the message the extension shows for a missing program.pathmode in the sandbox resolves to ahostplan, for the server and the CLI.customunder the host's/usris an error that nameshostmode. The file is shown to be visible on the host and not in the sandbox.comline --path <package> generationandgeneration clean, through the launch the extension builds, write and remove the generated code on disk;comline targetsruns; the oldgeneratefails.Set-up and exceptions:
ghcr.io/comlineproject/ci-flatpak(Add ci-flatpak: Flatpak's sandbox and Flathub's VSCodium at pinned commits ci-images#8), pinned by digest, with--privilegedbecause bubblewrap creates namespaces. The image holds Debian's flatpak, bubblewrap and xdg-dbus-proxy (apt pinned by a snapshot.debian.org timestamp) and Flathub'scom.vscodium.codiumwith its runtime, each at a pinned commit. Nothing is installed or cached while the job runs. The job logs both commits. The image's own checks confirm the app still has--filesystem=hostand--talk-name=org.freedesktop.Flatpak. Moving to a newer VSCodium is a deliberate commit bump in ci-images, then a digest bump here.comline-lspis built in this workflow fromcomline.languageServer.revinpackage.json, as the same static musl buildrelease.ymlbundles, so the test runs exactly what the next release ships. The sandbox job logs its sha256, which matches the build job's.comline(the CLI) has no release yet: it is built from a pinnedComlineProject/clicommit (e79092a, static musl, Rust generator only) in the CI tools image.maintouchingsrc/resolve.ts,src/extension.ts,package.json, the workflow or the script; weekly; manual.Not verified
com.visualstudio.code) is not run: only VSCodium is. Their manifests agree on the two permissions this needs.sleepsurvives) is what shows a check there can fail.~/.local/bininto the environmentdbus-run-sessionstarts the helper in, which is the behaviour described; a real desktop session's PATH is not tested.