Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(local-installation): preserve quoted paths in native environment files
Afloat92fe8ab5f4a2
diff --git a/packages/local-installation/AGENTS.md b/packages/local-installation/AGENTS.mdindex 6b900b95..05d60656 100644--- a/packages/local-installation/AGENTS.md+++ b/packages/local-installation/AGENTS.md@@ -35,6 +35,10 @@ voice key; without them, or when they fail to prepare, TeamHub gets`TEAMHUB_VOICE_MEDIA=off` and the install continues. The services' `voice`setting tracks only the tools, so a key change never restarts them throughit. A native process restarts when its generated environment changes.+Generated native values preserve quoted paths and literal backslashes by+checking their dotenv representation with the launcher's parser. Multiline,+NUL-containing or otherwise unrepresentable values fail before publishing+the environment file.Every port the installer chooses (`ports.ts`) must be free on both127.0.0.1 and ::1 with nothing answering there: `localhost` resolves to ::1first on macOS, and a program on ::1 alone would answer for a service thatdiff --git a/packages/local-installation/src/native-source.test.ts b/packages/local-installation/src/native-source.test.tsindex 65214c5f..317ed7a8 100644--- a/packages/local-installation/src/native-source.test.ts+++ b/packages/local-installation/src/native-source.test.ts@@ -91,6 +91,58 @@ test("native checkout identities are stable", async () => {await readFile(path.join(first.instance.root, "native.env"), "utf8"),).toBe(text);});++test.each(["O'Neil", "O'Neil`files"])(+ "native environments preserve paths below %s",+ async (directory) => {+ const f = await fixture();+ const native = await prepareNativeConfiguration(f.repo, {+ home: path.join(f.home, directory),+ name: "quoted-home",+ });+ const persisted = parseEnv(+ await readFile(path.join(native.instance.root, "native.env"), "utf8"),+ );+ for (const key of [+ "TEAMHUB_ARTIFACT_STORAGE_ROOT",+ "AGENT_HOME",+ "COMPUTER_RELEASE_DIR",+ ]) {+ expect(native.env[key]).toContain(directory);+ expect(persisted[key]).toBe(native.env[key]);+ }+ },+);++test("native environment quoting preserves literal Windows backslashes", async () => {+ const f = await fixture();+ const value = String.raw`C:\new\O'Neil\linger`;+ await writeFile(path.join(f.repo, ".env"), `FIXTURE_PATH=\`${value}\`\n`);+ const native = await prepareNativeConfiguration(f.repo, {+ home: f.home,+ name: "quoted-value",+ });+ const persisted = parseEnv(+ await readFile(path.join(native.instance.root, "native.env"), "utf8"),+ );+ expect(native.env.FIXTURE_PATH).toBe(value);+ expect(persisted.FIXTURE_PATH).toBe(value);+});++test("native environments still reject multiline values without publishing them", async () => {+ const f = await fixture();+ await writeFile(path.join(f.repo, ".env"), "FIXTURE_VALUE='line\nbreak'\n");+ await expect(+ prepareNativeConfiguration(f.repo, {+ home: f.home,+ name: "multiline-value",+ }),+ ).rejects.toThrow("Source environment contains unsupported characters.");+ await expect(+ readFile(path.join(f.home, "instances/multiline-value/native.env")),+ ).rejects.toMatchObject({ code: "ENOENT" });+});+test("native environment checks do not require or report Docker", async () => {const f = await fixture();const report = await checkNativeSourceEnvironment({diff --git a/packages/local-installation/src/source-checkout.ts b/packages/local-installation/src/source-checkout.tsindex a9d76034..f24e688e 100644--- a/packages/local-installation/src/source-checkout.ts+++ b/packages/local-installation/src/source-checkout.ts@@ -337,9 +337,14 @@ export async function prepareSourceConfiguration(),};const quote = (value: string) => {- if (/[\r\n\0']/.test(value))- throw new Error("Source environment contains unsupported characters.");- return `'${value}'`;+ if (!/[\r\n\0]/.test(value)) {+ // Match the launcher's parser, including literal Windows backslashes.+ for (const delimiter of ["'", "`", '"', ""]) {+ const quoted = `${delimiter}${value}${delimiter}`;+ if (parseEnv(`VALUE=${quoted}`).VALUE === value) return quoted;+ }+ }+ throw new Error("Source environment contains unsupported characters.");};const nativeFileOmissions = new Set(["WEB_HTTP_PORT",