Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: honor the injected env when scanning PATH for tailcat

Adam Eivyf072ebccadf3
diff --git a/server/services/tailcatPeer.js b/server/services/tailcatPeer.js
index bd842d365f..72098a4fa6 100644
--- a/server/services/tailcatPeer.js
+++ b/server/services/tailcatPeer.js
@@ -92,7 +92,7 @@ export function listCandidateTailcatBins({ env = process.env, home = homedir() }
const goBinDir = env.GOBIN || join(goPath, 'bin');
const brewPrefixes = [env.HOMEBREW_PREFIX, '/opt/homebrew', '/usr/local'].filter(Boolean);
const candidates = [
- findCommandOnPath('tailcat'),
+ findCommandOnPath('tailcat', { env }),
join(goBinDir, 'tailcat'),
join(goBinDir, 'tailcat.exe'),
...brewPrefixes.map((prefix) => join(prefix, 'bin', 'tailcat')),
diff --git a/server/services/tailcatPeer.test.js b/server/services/tailcatPeer.test.js
index 04e7e94a48..e0dda27fed 100644
--- a/server/services/tailcatPeer.test.js
+++ b/server/services/tailcatPeer.test.js
@@ -1,5 +1,6 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { EventEmitter } from 'node:events';
+import { delimiter, join } from 'node:path';
import {
redactTcAddress,
isValidTcAddress,
@@ -169,15 +170,25 @@ describe('tailcatPeer helpers', () => {
});
it('looks for tailcat in the GOBIN and Homebrew prefixes a server may not have on PATH', () => {
+ // Empty PATH so the injected env is the only source — the real PATH must not leak in.
const bins = listCandidateTailcatBins({
- env: { PATH: '', GOBIN: '/example/gobin', HOMEBREW_PREFIX: '/example/brew' },
- home: '/example/home',
+ env: { PATH: '', GOBIN: join('/example', 'gobin'), HOMEBREW_PREFIX: join('/example', 'brew') },
+ home: join('/example', 'home'),
});
- expect(bins).toContain('/example/gobin/tailcat');
- expect(bins).toContain('/example/brew/bin/tailcat');
- expect(bins).toContain('/opt/homebrew/bin/tailcat');
- expect(listCandidateTailcatBins({ env: { PATH: '', GOPATH: '/example/gopath' }, home: '/example/home' }))
- .toContain('/example/gopath/bin/tailcat');
+ expect(bins).toEqual([
+ join('/example', 'gobin', 'tailcat'),
+ join('/example', 'gobin', 'tailcat.exe'),
+ join('/example', 'brew', 'bin', 'tailcat'),
+ join('/opt', 'homebrew', 'bin', 'tailcat'),
+ join('/usr', 'local', 'bin', 'tailcat'),
+ ]);
+ // No GOBIN → the first GOPATH entry's bin; no GOPATH at all → ~/go/bin.
+ expect(listCandidateTailcatBins({
+ env: { PATH: '', GOPATH: [join('/example', 'gopath'), join('/example', 'other')].join(delimiter) },
+ home: join('/example', 'home'),
+ })).toContain(join('/example', 'gopath', 'bin', 'tailcat'));
+ expect(listCandidateTailcatBins({ env: { PATH: '' }, home: join('/example', 'home') }))
+ .toContain(join('/example', 'home', 'go', 'bin', 'tailcat'));
});
it('allocateLocalPort prefers 15555 then walks upward when busy', async () => {