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: derive the FLUX.2 venv dir with dirname instead of a separator-specific regex

[._.]/ Adam Eivy8b1211fee840
diff --git a/server/lib/pythonSetup.js b/server/lib/pythonSetup.js
index d78ef0cbed..631d652662 100644
--- a/server/lib/pythonSetup.js
+++ b/server/lib/pythonSetup.js
@@ -988,7 +988,11 @@ export function installFlux2Venv(onLog) {
if (killed) return { ok: false, stage: 'detect', cancelled: true };
stage('venv', `Creating FLUX.2 venv at ${FLUX2_VENV_DEFAULT}…`);
- const targetDir = FLUX2_VENV_DEFAULT.replace(IS_WIN ? /\\Scripts\\python\.exe$/ : /\/bin\/python3$/, '');
+ // `<venv>/bin/python3` (or `<venv>\\Scripts\\python.exe`) → `<venv>`. Two
+ // dirnames rather than a separator-specific regex: the regex silently
+ // no-ops on the other platform's spelling, leaving targetDir pointing at
+ // the interpreter itself and the venv nested a level too deep.
+ const targetDir = dirname(dirname(FLUX2_VENV_DEFAULT));
// createVenv reuses an existing interpreter as-is, so a venv left behind by
// an earlier run against a too-old base would survive every retry — and
// keep failing the same way. Rebuild it rather than pip into it.
diff --git a/server/lib/pythonSetup.test.js b/server/lib/pythonSetup.test.js
index 5f88452b98..c5392449e5 100644
--- a/server/lib/pythonSetup.test.js
+++ b/server/lib/pythonSetup.test.js
@@ -34,6 +34,11 @@ const mockState = {
venvCalls: [],
};
+// pythonSetup composes paths with path.join, which is backslashed on a Windows
+// runner while every fixture below is written POSIX-style. One normalizer,
+// shared by the fs and childProcess mocks.
+const toPosix = (p) => String(p).split('\\').join('/');
+
vi.mock('node:os', async () => {
const actual = await vi.importActual('node:os');
return {
@@ -52,7 +57,7 @@ vi.mock('node:fs', async () => {
// fixtures — the module's own platform is pinned via mockState.platform.
return {
...actual,
- existsSync: (p) => mockState.presentPaths.has(String(p).split('\\').join('/')),
+ existsSync: (p) => mockState.presentPaths.has(toPosix(p)),
// uv's install root is enumerated rather than listed, so the candidate
// builder readdirs it. `null` means "uv not installed" — the common case —
// and must throw the way the real readdirSync does so the builder swallows
@@ -81,11 +86,15 @@ vi.mock('./childProcess.js', async () => {
// Mimic `python -m venv`: record the invocation and make the resulting
// interpreter exist, so createVenv's post-condition check passes.
mockState.venvCalls.push([bin, ...args]);
- mockState.presentPaths.add(`${args[args.length - 1]}/bin/python3`);
+ // presentPaths holds POSIX spellings; `join` gives the mock a
+ // backslashed targetDir on a Windows runner, so normalize like the
+ // existsSync mock does or the created interpreter never "exists".
+ mockState.presentPaths.add(toPosix(`${args[args.length - 1]}/bin/python3`));
resolve({ stdout: '', stderr: '' });
} else if (probeArg.includes('sys.version_info')) {
- const version = mockState.versionByPath.has(bin)
- ? mockState.versionByPath.get(bin)
+ const key = toPosix(bin);
+ const version = mockState.versionByPath.has(key)
+ ? mockState.versionByPath.get(key)
: mockState.defaultVersion;
if (!version) reject(new Error('not an interpreter'));
else resolve({ stdout: `${version}\n`, stderr: '' });