Skip to content

Commit a9e81c8

Browse files
jdaltonclaude
andcommitted
fix: handle pnpm frozen-lockfile in CI for optimize command
In CI environments, pnpm automatically runs with --frozen-lockfile which prevents lockfile updates. When the optimize command tries to add overrides and update the lockfile, it fails with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Added explicit --no-frozen-lockfile flag when running pnpm install in CI mode to allow the lockfile to be updated with Socket.dev overrides. Used constants.ENV[constants.CI] to properly detect CI environment at runtime instead of build-time frozen constants.ENV.CI value. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1959c61 commit a9e81c8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/utils/agent.mts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ export function runAgentInstall(
3838
...spawnOpts
3939
} = { __proto__: null, ...options } as AgentInstallOptions
4040
const skipNodeHardenFlags = isPnpm && pkgEnvDetails.agentVersion.major < 11
41-
return spawn(agentExecPath, ['install', ...args], {
41+
// In CI mode, pnpm uses --frozen-lockfile by default, which prevents lockfile updates.
42+
// We need to explicitly disable it when updating the lockfile with overrides.
43+
const isCi = !!constants.ENV[constants.CI]
44+
const installArgs = isPnpm && isCi
45+
? ['install', '--no-frozen-lockfile', ...args]
46+
: ['install', ...args]
47+
48+
return spawn(agentExecPath, installArgs, {
4249
cwd: pkgPath,
4350
shell: constants.WIN32,
4451
spinner,

src/utils/package-environment.mts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,14 @@ async function getAgentExecPath(agent: Agent): Promise<string> {
213213
if (existsSync(npmPath)) {
214214
return npmPath
215215
}
216-
// If npmExecPath doesn't exist, fall back to whichBin.
216+
// If npmExecPath doesn't exist, try common locations.
217+
// Check npm in the same directory as node.
218+
const nodeDir = path.dirname(process.execPath)
219+
const npmInNodeDir = path.join(nodeDir, 'npm')
220+
if (existsSync(npmInNodeDir)) {
221+
return npmInNodeDir
222+
}
223+
// Fall back to whichBin.
217224
return (await whichBin(binName, { nothrow: true })) ?? binName
218225
}
219226
return (await whichBin(binName, { nothrow: true })) ?? binName

0 commit comments

Comments
 (0)