Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Stop Linux folder picker crashing under added capabilities (PRD-8831) (#5050)
Andrew Mikofalvy6b4e44472b3e
diff --git a/.changeset/prd-8831-linux-ambient-caps.md b/.changeset/prd-8831-linux-ambient-caps.mdnew file mode 100644index 000000000..1123f9800--- /dev/null+++ b/.changeset/prd-8831-linux-ambient-caps.md@@ -0,0 +1,6 @@+---+"@inkeep/open-knowledge": patch+"@inkeep/open-knowledge-desktop": patch+---++On Linux, the desktop app no longer crashes when a native dialog or other system UI loads icons inside a container that grants extra capabilities, such as x11docker with `--cap-add`. The reported trigger was the folder picker.diff --git a/packages/desktop/src/main/entry.ts b/packages/desktop/src/main/entry.tsindex 00db22713..54724bb07 100644--- a/packages/desktop/src/main/entry.ts+++ b/packages/desktop/src/main/entry.ts@@ -1,9 +1,24 @@+import { existsSync, readFileSync } from 'node:fs';import { app } from 'electron';import {parseDesktopUninstallResultArgs,UNINSTALL_PROGRESS_ARG,UNINSTALL_RESULT_ARG,} from './desktop-uninstall-result.ts';+import { isExecutableFileSync } from './executable-file.ts';+import { clearAmbientCapsBeforeBoot } from './linux-ambient-caps.ts';++clearAmbientCapsBeforeBoot({+ platform: process.platform,+ uid: process.getuid?.() ?? -1,+ env: process.env,+ readProcStatus: () => readFileSync('/proc/self/status', 'utf8'),+ exists: existsSync,+ isExecutable: (path) => isExecutableFileSync(path),+ execPath: process.execPath,+ argv: process.argv,+ execve: process.execve?.bind(process),+});if (process.argv.includes(UNINSTALL_RESULT_ARG) || process.argv.includes(UNINSTALL_PROGRESS_ARG)) {const options = parseDesktopUninstallResultArgs(process.argv);diff --git a/packages/desktop/src/main/executable-file.test.ts b/packages/desktop/src/main/executable-file.test.tsnew file mode 100644index 000000000..6acbf5b2e--- /dev/null+++ b/packages/desktop/src/main/executable-file.test.ts@@ -0,0 +1,46 @@+import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { isExecutableFileSync } from './executable-file.ts';++describe('isExecutableFileSync', () => {+ let dir: string;+ beforeEach(() => {+ dir = mkdtempSync(join(tmpdir(), 'executable-file-'));+ });+ afterEach(() => {+ rmSync(dir, { recursive: true, force: true });+ });++ it('accepts a regular file with the execute bit', () => {+ const bin = join(dir, 'setpriv');+ writeFileSync(bin, '#!/bin/sh\n');+ chmodSync(bin, 0o755);+ expect(isExecutableFileSync(bin, 'linux')).toBe(true);+ });++ it('rejects a regular file without the execute bit where the host enforces it', () => {+ const bin = join(dir, 'setpriv');+ writeFileSync(bin, '#!/bin/sh\n');+ chmodSync(bin, 0o644);+ expect(isExecutableFileSync(bin, 'linux')).toBe(process.platform === 'win32');+ });++ it('rejects a directory even though access(X_OK) passes on it', () => {+ const sub = join(dir, 'setpriv');+ mkdirSync(sub, { mode: 0o755 });+ expect(isExecutableFileSync(sub, 'linux')).toBe(false);+ });++ it('rejects a path that does not exist', () => {+ expect(isExecutableFileSync(join(dir, 'missing'), 'linux')).toBe(false);+ });++ it('treats any regular file as executable on Windows', () => {+ const file = join(dir, 'tool.cmd');+ writeFileSync(file, '@echo off\n');+ chmodSync(file, 0o644);+ expect(isExecutableFileSync(file, 'win32')).toBe(true);+ });+});diff --git a/packages/desktop/src/main/executable-file.ts b/packages/desktop/src/main/executable-file.tsnew file mode 100644index 000000000..995787712--- /dev/null+++ b/packages/desktop/src/main/executable-file.ts@@ -0,0 +1,15 @@+import { accessSync, constants, statSync } from 'node:fs';++export function isExecutableFileSync(+ absPath: string,+ platform: NodeJS.Platform = process.platform,+): boolean {+ try {+ if (!statSync(absPath).isFile()) return false;+ if (platform === 'win32') return true;+ accessSync(absPath, constants.X_OK);+ return true;+ } catch {+ return false;+ }+}diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.tsindex e51da44b0..7dba788aa 100644--- a/packages/desktop/src/main/index.ts+++ b/packages/desktop/src/main/index.ts@@ -332,6 +332,7 @@ import {} from './ipc-handlers.ts';import { logIpcError, withIpcErrorLogging } from './ipc-log.ts';import { createDesktopKeepaliveFactory, toKeepaliveLogger } from './keepalive.ts';+import { getBootAmbientCapsFacts, logAmbientCapsPosture } from './linux-ambient-caps.ts';import {detectGraphicalAuthCommand,runManualInstallFallbackDialog,@@ -5898,6 +5899,13 @@ applyDevShmPosture({getRootDesktopLogger()[level](facts, 'linux shared-memory posture for chromium'),});+const bootAmbientCapsFacts = getBootAmbientCapsFacts();+if (bootAmbientCapsFacts) {+ logAmbientCapsPosture(bootAmbientCapsFacts, (level, facts) =>+ getRootDesktopLogger()[level](facts, 'linux ambient capabilities posture'),+ );+}+if (!app.isPackaged) {const resolved = resolveEffectiveInstanceName(process.env, app.getAppPath(), {autoDeriveEnabled: process.env.OK_DESKTOP_E2E_SMOKE !== '1',diff --git a/packages/desktop/src/main/linux-ambient-caps.ts b/packages/desktop/src/main/linux-ambient-caps.tsnew file mode 100644index 000000000..d8d3f32ab--- /dev/null+++ b/packages/desktop/src/main/linux-ambient-caps.ts@@ -0,0 +1,163 @@+import { errorCodeOf } from './linux-shm-posture.ts';++export const AMBIENT_CAPS_CLEARED_ENV = 'OK_AMBIENT_CAPS_CLEARED';+const SETPRIV_PATHS = ['/usr/bin/setpriv', '/bin/setpriv'] as const;++type AmbientCapsDecision =+ | 'not-linux'+ | 'root'+ | 'none'+ | 'status-unreadable'+ | 'reexec'+ | 'setpriv-missing'+ | 'setpriv-not-executable'+ | 'reexec-failed'+ | 'cleared'+ | 'still-present';++const AMBIENT_CAPS_LOG_LEVELS = {+ 'not-linux': null,+ root: null,+ none: null,+ reexec: null,+ 'status-unreadable': 'warn',+ 'setpriv-missing': 'warn',+ 'setpriv-not-executable': 'warn',+ 'reexec-failed': 'warn',+ cleared: 'info',+ 'still-present': 'warn',+} satisfies Record<AmbientCapsDecision, 'info' | 'warn' | null>;++export interface AmbientCapsDeps {+ platform: NodeJS.Platform;+ uid: number;+ env: NodeJS.ProcessEnv;+ readProcStatus: () => string;+ exists: (path: string) => boolean;+ isExecutable: (path: string) => boolean;+ execPath: string;+ argv: readonly string[];+}++interface AmbientCapsExec {+ file: string;+ args: string[];+ env: NodeJS.ProcessEnv;+}++export interface AmbientCapsPosture {+ decision: AmbientCapsDecision;+ event: 'desktop.linux-ambient-caps-posture';+ ambientCaps: string | null;+ clearedFrom: string | null;+ errorCode: string | null;+ exec: AmbientCapsExec | null;+}++export type AmbientCapsFacts = Omit<AmbientCapsPosture, 'exec'>;++export function parseAmbientCaps(procStatus: string): bigint | null {+ const match = /^CapAmb:\s*([0-9a-f]+)$/m.exec(procStatus);+ return match ? BigInt(`0x${match[1]}`) : null;+}++export function planAmbientCapsReexec(deps: AmbientCapsDeps): AmbientCapsPosture {+ const posture: AmbientCapsPosture = {+ decision: 'not-linux',+ event: 'desktop.linux-ambient-caps-posture',+ ambientCaps: null,+ clearedFrom: deps.env[AMBIENT_CAPS_CLEARED_ENV] ?? null,+ errorCode: null,+ exec: null,+ };+ if (deps.platform !== 'linux') return posture;+ if (deps.uid === 0) {+ posture.decision = 'root';+ return posture;+ }++ let ambient: bigint | null;+ try {+ ambient = parseAmbientCaps(deps.readProcStatus());+ } catch (error) {+ posture.decision = 'status-unreadable';+ posture.errorCode = errorCodeOf(error);+ return posture;+ }+ if (ambient === null) {+ posture.decision = 'status-unreadable';+ return posture;+ }+ posture.ambientCaps = ambient.toString(16);++ if (posture.clearedFrom !== null) {+ posture.decision = ambient === 0n ? 'cleared' : 'still-present';+ return posture;+ }+ if (ambient === 0n) {+ posture.decision = 'none';+ return posture;+ }++ const setpriv = SETPRIV_PATHS.find((path) => deps.isExecutable(path));+ if (setpriv === undefined) {+ posture.decision = SETPRIV_PATHS.some((path) => deps.exists(path))+ ? 'setpriv-not-executable'+ : 'setpriv-missing';+ return posture;+ }+ posture.decision = 'reexec';+ posture.exec = {+ file: setpriv,+ args: [setpriv, '--inh-caps=-all', '--ambient-caps=-all', deps.execPath, ...deps.argv.slice(1)],+ env: { ...deps.env, [AMBIENT_CAPS_CLEARED_ENV]: posture.ambientCaps },+ };+ return posture;+}++type Execve = (file: string, args: string[], env: NodeJS.ProcessEnv) => void;++let bootFacts: AmbientCapsFacts | null = null;++export function clearAmbientCapsBeforeBoot(+ deps: AmbientCapsDeps & { execve: Execve | undefined },+): AmbientCapsPosture {+ const posture = planAmbientCapsReexec(deps);+ delete deps.env[AMBIENT_CAPS_CLEARED_ENV];+ attemptReexec(posture, deps.execve);+ bootFacts = factsOf(posture);+ return posture;+}++function attemptReexec(posture: AmbientCapsPosture, execve: Execve | undefined): void {+ if (posture.exec === null) return;+ if (execve === undefined) {+ posture.decision = 'reexec-failed';+ posture.errorCode = 'EXECVE_UNAVAILABLE';+ return;+ }+ try {+ execve(posture.exec.file, posture.exec.args, posture.exec.env);+ } catch (error) {+ posture.decision = 'reexec-failed';+ posture.errorCode = errorCodeOf(error);+ }+}++export function getBootAmbientCapsFacts(): AmbientCapsFacts | null {+ return bootFacts;+}++function factsOf(posture: AmbientCapsPosture): AmbientCapsFacts {+ const { exec: _exec, ...facts } = posture;+ return facts;+}++export function logAmbientCapsPosture(+ facts: AmbientCapsFacts,+ log: (level: 'info' | 'warn', facts: AmbientCapsFacts) => void,+): void {+ const level = AMBIENT_CAPS_LOG_LEVELS[facts.decision];+ if (level === null) return;+ log(level, facts);+}diff --git a/packages/desktop/src/main/linux-shm-posture.ts b/packages/desktop/src/main/linux-shm-posture.tsindex 49a35393a..90c5a9e65 100644--- a/packages/desktop/src/main/linux-shm-posture.ts+++ b/packages/desktop/src/main/linux-shm-posture.ts@@ -55,17 +55,19 @@ function measure(statfs: DevShmPostureDeps['statfs'], path: string): MeasuredSpaerrorCode: null,};} catch (error) {- const errorCode =- error !== null &&- typeof error === 'object' &&- 'code' in error &&- typeof error.code === 'string'- ? error.code- : 'UNKNOWN';- return { available: null, total: null, errorCode };+ return { available: null, total: null, errorCode: errorCodeOf(error) };}}+export function errorCodeOf(error: unknown): string {+ return error !== null &&+ typeof error === 'object' &&+ 'code' in error &&+ typeof error.code === 'string'+ ? error.code+ : 'UNKNOWN';+}+export function decideDevShmPosture(deps: DevShmPostureDeps): DevShmPosture {const posture: DevShmPosture = {decision: 'not-linux',diff --git a/packages/desktop/src/main/slidev-resolve.ts b/packages/desktop/src/main/slidev-resolve.tsindex 7cef13afc..acf3cc06e 100644--- a/packages/desktop/src/main/slidev-resolve.ts+++ b/packages/desktop/src/main/slidev-resolve.ts@@ -1,6 +1,6 @@-import { access, constants, stat } from 'node:fs/promises';import { join } from 'node:path';import type { SlidevSource } from '../shared/ipc-channels.ts';+import { isExecutableFileSync } from './executable-file.ts';type SlidevResolution = { available: true; source: SlidevSource } | { available: false };@@ -31,13 +31,5 @@ export async function resolveSlidev(}export async function realIsExecutableFile(absPath: string): Promise<boolean> {- try {- const st = await stat(absPath);- if (!st.isFile()) return false;- if (process.platform === 'win32') return true;- await access(absPath, constants.X_OK);- return true;- } catch {- return false;- }+ return isExecutableFileSync(absPath);}diff --git a/packages/desktop/tests/main/linux-ambient-caps.test.ts b/packages/desktop/tests/main/linux-ambient-caps.test.tsnew file mode 100644index 000000000..c652437ea--- /dev/null+++ b/packages/desktop/tests/main/linux-ambient-caps.test.ts@@ -0,0 +1,294 @@+import { describe, expect, test } from 'vitest';+import {+ AMBIENT_CAPS_CLEARED_ENV,+ type AmbientCapsDeps,+ clearAmbientCapsBeforeBoot,+ getBootAmbientCapsFacts,+ logAmbientCapsPosture,+ parseAmbientCaps,+ planAmbientCapsReexec,+} from '../../src/main/linux-ambient-caps.ts';++const EXEC_PATH = '/opt/OpenKnowledge/openknowledge';++function procStatus(capAmb: string): string {+ return [+ 'Name:\topenknowledge',+ 'Uid:\t1000\t1000\t1000\t1000',+ 'CapInh:\t0000000000000001',+ 'CapPrm:\t0000000000000001',+ 'CapEff:\t0000000000000001',+ 'CapBnd:\t0000000000000001',+ `CapAmb:\t${capAmb}`,+ 'NoNewPrivs:\t1',+ ].join('\n');+}++function deps(overrides: Partial<AmbientCapsDeps> = {}): AmbientCapsDeps & {+ statusReads: number;+} {+ const base = {+ platform: 'linux' as NodeJS.Platform,+ uid: 1000,+ env: { DISPLAY: ':0' } as NodeJS.ProcessEnv,+ exists: (path: string) => path === '/usr/bin/setpriv',+ isExecutable: (path: string) => path === '/usr/bin/setpriv',+ execPath: EXEC_PATH,+ argv: [EXEC_PATH, '--no-sandbox', '--password-store=basic'],+ statusReads: 0,+ readProcStatus: () => '',+ };+ const result = { ...base, ...overrides };+ const read = overrides.readProcStatus ?? (() => procStatus('0000000000000001'));+ result.readProcStatus = () => {+ result.statusReads += 1;+ return read();+ };+ return result;+}++function withExecve(+ d: AmbientCapsDeps,+ execve: (file: string, args: string[], env: NodeJS.ProcessEnv) => void,+) {+ return { ...d, execve };+}++describe('parseAmbientCaps', () => {+ test('reads the CapAmb mask from /proc/self/status', () => {+ expect(parseAmbientCaps(procStatus('0000000000000001'))).toBe(1n);+ expect(parseAmbientCaps(procStatus('000001ffffffffff'))).toBe(0x1ffffffffffn);+ expect(parseAmbientCaps(procStatus('0000000000000000'))).toBe(0n);+ });++ test('a kernel without ambient capabilities has no CapAmb line', () => {+ expect(parseAmbientCaps('Name:\tx\nCapPrm:\t0000000000000000\n')).toBeNull();+ });+});++describe('planAmbientCapsReexec', () => {+ test('non-linux platforms never read /proc and never re-exec', () => {+ for (const platform of ['darwin', 'win32'] as const) {+ const d = deps({ platform });+ const posture = planAmbientCapsReexec(d);+ expect(posture.decision).toBe('not-linux');+ expect(posture.exec).toBeNull();+ expect(d.statusReads).toBe(0);+ }+ });++ test('root keeps its capabilities because bubblewrap accepts them for uid 0', () => {+ const d = deps({ uid: 0 });+ expect(planAmbientCapsReexec(d)).toMatchObject({ decision: 'root', exec: null });+ expect(d.statusReads).toBe(0);+ });++ test('a process without ambient capabilities boots as-is', () => {+ const posture = planAmbientCapsReexec(+ deps({ readProcStatus: () => procStatus('0000000000000000') }),+ );+ expect(posture).toMatchObject({ decision: 'none', ambientCaps: '0', exec: null });+ });++ test('ambient capabilities re-exec the same argv through setpriv with them dropped', () => {+ const posture = planAmbientCapsReexec(deps());+ expect(posture.decision).toBe('reexec');+ expect(posture.ambientCaps).toBe('1');+ expect(posture.exec).toEqual({+ file: '/usr/bin/setpriv',+ args: [+ '/usr/bin/setpriv',+ '--inh-caps=-all',+ '--ambient-caps=-all',+ EXEC_PATH,+ '--no-sandbox',+ '--password-store=basic',+ ],+ env: { DISPLAY: ':0', [AMBIENT_CAPS_CLEARED_ENV]: '1' },+ });+ });++ test('a /usr/bin/setpriv that is not executable is skipped for /bin/setpriv', () => {+ const posture = planAmbientCapsReexec(+ deps({ isExecutable: (path) => path === '/bin/setpriv' }),+ );+ expect(posture.exec?.file).toBe('/bin/setpriv');+ });++ test('without setpriv at either path the app boots with the capabilities still set', () => {+ const posture = planAmbientCapsReexec(deps({ exists: () => false, isExecutable: () => false }));+ expect(posture).toMatchObject({ decision: 'setpriv-missing', ambientCaps: '1', exec: null });+ });++ test('a setpriv that exists but cannot be executed is reported apart from a missing one', () => {+ const posture = planAmbientCapsReexec(deps({ isExecutable: () => false }));+ expect(posture).toMatchObject({+ decision: 'setpriv-not-executable',+ ambientCaps: '1',+ exec: null,+ });+ });++ test('after the re-exec, a cleared mask is recorded and never re-execs again', () => {+ const posture = planAmbientCapsReexec(+ deps({+ env: { [AMBIENT_CAPS_CLEARED_ENV]: '1' },+ readProcStatus: () => procStatus('0000000000000000'),+ }),+ );+ expect(posture).toMatchObject({+ decision: 'cleared',+ clearedFrom: '1',+ ambientCaps: '0',+ exec: null,+ });+ });++ test('capabilities that survive the re-exec are reported instead of looping', () => {+ const posture = planAmbientCapsReexec(deps({ env: { [AMBIENT_CAPS_CLEARED_ENV]: '1' } }));+ expect(posture).toMatchObject({ decision: 'still-present', ambientCaps: '1', exec: null });+ });++ test('an unreadable /proc/self/status leaves the process alone', () => {+ const error = Object.assign(new Error('EACCES'), { code: 'EACCES' });+ const unreadable = planAmbientCapsReexec(+ deps({+ readProcStatus: () => {+ throw error;+ },+ }),+ );+ expect(unreadable).toMatchObject({+ decision: 'status-unreadable',+ errorCode: 'EACCES',+ exec: null,+ });++ const noLine = planAmbientCapsReexec(deps({ readProcStatus: () => 'Name:\tx\n' }));+ expect(noLine).toMatchObject({ decision: 'status-unreadable', errorCode: null, exec: null });+ });+});++describe('clearAmbientCapsBeforeBoot', () => {+ test('execs the planned command exactly once', () => {+ const calls: Array<[string, string[], NodeJS.ProcessEnv]> = [];+ clearAmbientCapsBeforeBoot(withExecve(deps(), (...args) => calls.push(args)));+ expect(calls).toHaveLength(1);+ expect(calls[0]?.[0]).toBe('/usr/bin/setpriv');+ expect(calls[0]?.[2][AMBIENT_CAPS_CLEARED_ENV]).toBe('1');+ });++ test('does not exec when there is nothing to drop', () => {+ let called = false;+ const posture = clearAmbientCapsBeforeBoot(+ withExecve(deps({ readProcStatus: () => procStatus('0000000000000000') }), () => {+ called = true;+ }),+ );+ expect(called).toBe(false);+ expect(posture.decision).toBe('none');+ });++ test('an execve that throws on its arguments keeps booting and records the error', () => {+ const posture = clearAmbientCapsBeforeBoot(+ withExecve(deps(), () => {+ throw Object.assign(new TypeError('bad argument'), { code: 'ERR_INVALID_ARG_TYPE' });+ }),+ );+ expect(posture).toMatchObject({ decision: 'reexec-failed', errorCode: 'ERR_INVALID_ARG_TYPE' });+ });++ test('a runtime without process.execve keeps booting and says so', () => {+ const posture = clearAmbientCapsBeforeBoot({ ...deps(), execve: undefined });+ expect(posture).toMatchObject({ decision: 'reexec-failed', errorCode: 'EXECVE_UNAVAILABLE' });+ });++ test('the re-exec marker does not leak into processes the app spawns later', () => {+ const env: NodeJS.ProcessEnv = { [AMBIENT_CAPS_CLEARED_ENV]: '1', DISPLAY: ':0' };+ clearAmbientCapsBeforeBoot(+ withExecve(deps({ env, readProcStatus: () => procStatus('0000000000000000') }), () => {}),+ );+ expect(env).toEqual({ DISPLAY: ':0' });+ });+});++describe('boot facts handed to the logger', () => {+ function bootFacts(+ d: AmbientCapsDeps,+ execve: (file: string, args: string[], env: NodeJS.ProcessEnv) => void = () => {},+ ) {+ clearAmbientCapsBeforeBoot(withExecve(d, execve));+ return getBootAmbientCapsFacts();+ }++ function logged(+ d: AmbientCapsDeps,+ execve?: (file: string, args: string[], env: NodeJS.ProcessEnv) => void,+ ) {+ const facts = bootFacts(d, execve);+ if (facts === null) throw new Error('expected boot facts');+ const lines: Array<{ level: string; facts: object }> = [];+ logAmbientCapsPosture(facts, (level, logFacts) => lines.push({ level, facts: logFacts }));+ return lines;+ }++ test('the getter returns the decision clearAmbientCapsBeforeBoot reached, without the exec or environment', () => {+ const posture = clearAmbientCapsBeforeBoot({+ ...deps({ env: { SECRET: 'x' } }),+ execve: undefined,+ });+ const facts = getBootAmbientCapsFacts();+ expect(facts).toEqual({+ decision: 'reexec-failed',+ event: 'desktop.linux-ambient-caps-posture',+ ambientCaps: '1',+ clearedFrom: null,+ errorCode: 'EXECVE_UNAVAILABLE',+ });+ expect(facts?.decision).toBe(posture.decision);+ expect(JSON.stringify(facts)).not.toContain('SECRET');+ });++ test('the common paths stay quiet', () => {+ expect(logged(deps({ platform: 'darwin' }))).toEqual([]);+ expect(logged(deps({ uid: 0 }))).toEqual([]);+ expect(logged(deps({ readProcStatus: () => procStatus('0000000000000000') }))).toEqual([]);+ });++ test('a cleared boot logs info with the mask it started with', () => {+ const lines = logged(+ deps({+ env: { [AMBIENT_CAPS_CLEARED_ENV]: '200000' },+ readProcStatus: () => procStatus('0000000000000000'),+ }),+ );+ expect(lines).toEqual([+ {+ level: 'info',+ facts: {+ decision: 'cleared',+ event: 'desktop.linux-ambient-caps-posture',+ ambientCaps: '0',+ clearedFrom: '200000',+ errorCode: null,+ },+ },+ ]);+ });++ test('every outcome that leaves capabilities in place warns', () => {+ const throwing = () => {+ throw Object.assign(new Error('EINVAL'), { code: 'ERR_INVALID_ARG_VALUE' });+ };+ const leftInPlace = [+ logged(deps({ exists: () => false, isExecutable: () => false })),+ logged(deps({ isExecutable: () => false })),+ logged(deps({ env: { [AMBIENT_CAPS_CLEARED_ENV]: '1' } })),+ logged(deps({ readProcStatus: () => 'Name:\tx\n' })),+ logged(deps(), throwing),+ ];+ for (const lines of leftInPlace) {+ expect(lines.map((line) => line.level)).toEqual(['warn']);+ }+ });+});