Compare commits
1 Commits
feat/issue
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93c5aefd9e |
13
.env.example
13
.env.example
@@ -421,16 +421,3 @@ ANTHROPIC_API_KEY=sk-ant-your-key-here
|
||||
# WEB_CUSTOM_ALLOW_HTTP=false — set "true" to allow http:// URLs
|
||||
# WEB_CUSTOM_ALLOW_PRIVATE=false — set "true" to target localhost/private IPs
|
||||
# (needed for self-hosted SearXNG)
|
||||
|
||||
# ── Config directory override ───────────────────────────────────────
|
||||
#
|
||||
# By default openclaude stores per-user state under ~/.openclaude
|
||||
# (and falls back to ~/.claude for installs that pre-date the rename).
|
||||
# Set this to point openclaude at a different directory — useful for
|
||||
# isolating profiles or sharing config across machines.
|
||||
#
|
||||
# OPENCLAUDE_CONFIG_DIR=/path/to/dir — preferred name
|
||||
# CLAUDE_CONFIG_DIR=/path/to/dir — legacy alias (still works)
|
||||
#
|
||||
# When both are set with different values, OPENCLAUDE_CONFIG_DIR wins
|
||||
# and a warning is logged once per process.
|
||||
|
||||
@@ -3,11 +3,7 @@ import { homedir } from 'os'
|
||||
import { join } from 'path'
|
||||
import { fileSuffixForOauthConfig } from '../constants/oauth.js'
|
||||
import { isRunningWithBun } from './bundledMode.js'
|
||||
import {
|
||||
getClaudeConfigHomeDir,
|
||||
isEnvTruthy,
|
||||
resolveConfigDirEnv,
|
||||
} from './envUtils.js'
|
||||
import { getClaudeConfigHomeDir, isEnvTruthy } from './envUtils.js'
|
||||
import { findExecutable } from './findExecutable.js'
|
||||
import { getFsImplementation } from './fsOperations.js'
|
||||
import { which } from './which.js'
|
||||
@@ -26,11 +22,7 @@ export const getGlobalClaudeFile = memoize((): string => {
|
||||
}
|
||||
|
||||
const oauthSuffix = fileSuffixForOauthConfig()
|
||||
const configDir =
|
||||
resolveConfigDirEnv({
|
||||
openClaudeConfigDir: process.env.OPENCLAUDE_CONFIG_DIR,
|
||||
legacyConfigDir: process.env.CLAUDE_CONFIG_DIR,
|
||||
}) ?? homedir()
|
||||
const configDir = process.env.CLAUDE_CONFIG_DIR || homedir()
|
||||
|
||||
// Default to .openclaude.json. Fall back to .claude.json only if the new
|
||||
// file doesn't exist yet and the legacy one does (same migration pattern
|
||||
|
||||
@@ -3,39 +3,6 @@ import { existsSync } from 'fs'
|
||||
import { homedir } from 'os'
|
||||
import { join } from 'path'
|
||||
|
||||
/**
|
||||
* Resolves the override env value for the config home directory.
|
||||
* `OPENCLAUDE_CONFIG_DIR` is preferred — `CLAUDE_CONFIG_DIR` is the legacy
|
||||
* Anthropic name kept working for backward compatibility. When both are set
|
||||
* and disagree, `OPENCLAUDE_CONFIG_DIR` wins and we warn once so the user
|
||||
* can clean up. Exported for tests.
|
||||
*/
|
||||
let warnedAboutConflictingConfigDirEnvs = false
|
||||
|
||||
export function resolveConfigDirEnv(options?: {
|
||||
openClaudeConfigDir?: string
|
||||
legacyConfigDir?: string
|
||||
warn?: (message: string) => void
|
||||
}): string | undefined {
|
||||
const open = options?.openClaudeConfigDir
|
||||
const legacy = options?.legacyConfigDir
|
||||
if (open && legacy && open !== legacy && !warnedAboutConflictingConfigDirEnvs) {
|
||||
warnedAboutConflictingConfigDirEnvs = true
|
||||
options?.warn?.(
|
||||
`Both OPENCLAUDE_CONFIG_DIR and CLAUDE_CONFIG_DIR are set to different values. Using OPENCLAUDE_CONFIG_DIR=${open}; ignoring CLAUDE_CONFIG_DIR=${legacy}.`,
|
||||
)
|
||||
}
|
||||
return open || legacy || undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-only escape hatch — resets the once-per-process conflict warning so
|
||||
* unit tests can re-trigger it.
|
||||
*/
|
||||
export function __resetConfigDirEnvWarningForTesting(): void {
|
||||
warnedAboutConflictingConfigDirEnvs = false
|
||||
}
|
||||
|
||||
export function resolveClaudeConfigHomeDir(options?: {
|
||||
configDirEnv?: string
|
||||
homeDir?: string
|
||||
@@ -63,21 +30,13 @@ export function resolveClaudeConfigHomeDir(options?: {
|
||||
return openClaudeDir.normalize('NFC')
|
||||
}
|
||||
|
||||
// Memoized: 150+ callers, many on hot paths. Keyed off both override env
|
||||
// vars so tests that change either get a fresh value without explicit
|
||||
// cache.clear.
|
||||
// Memoized: 150+ callers, many on hot paths. Keyed off CLAUDE_CONFIG_DIR so
|
||||
// tests that change the env var get a fresh value without explicit cache.clear.
|
||||
export const getClaudeConfigHomeDir = memoize(
|
||||
(): string => resolveClaudeConfigHomeDir({
|
||||
configDirEnv: resolveConfigDirEnv({
|
||||
openClaudeConfigDir: process.env.OPENCLAUDE_CONFIG_DIR,
|
||||
legacyConfigDir: process.env.CLAUDE_CONFIG_DIR,
|
||||
warn: message => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`[openclaude] ${message}`)
|
||||
},
|
||||
configDirEnv: process.env.CLAUDE_CONFIG_DIR,
|
||||
}),
|
||||
}),
|
||||
() => `${process.env.OPENCLAUDE_CONFIG_DIR ?? ''}|${process.env.CLAUDE_CONFIG_DIR ?? ''}`,
|
||||
() => process.env.CLAUDE_CONFIG_DIR,
|
||||
)
|
||||
|
||||
export function getTeamsDir(): string {
|
||||
|
||||
@@ -51,8 +51,7 @@ describe('OpenClaude paths', () => {
|
||||
).toBe(join(homedir(), '.claude'))
|
||||
})
|
||||
|
||||
test('uses CLAUDE_CONFIG_DIR override when provided (legacy)', async () => {
|
||||
delete process.env.OPENCLAUDE_CONFIG_DIR
|
||||
test('uses CLAUDE_CONFIG_DIR override when provided', async () => {
|
||||
process.env.CLAUDE_CONFIG_DIR = '/tmp/custom-openclaude'
|
||||
const { getClaudeConfigHomeDir, resolveClaudeConfigHomeDir } =
|
||||
await importFreshEnvUtils()
|
||||
@@ -65,83 +64,6 @@ describe('OpenClaude paths', () => {
|
||||
).toBe('/tmp/custom-openclaude')
|
||||
})
|
||||
|
||||
test('OPENCLAUDE_CONFIG_DIR overrides the default (issue #454)', async () => {
|
||||
delete process.env.CLAUDE_CONFIG_DIR
|
||||
process.env.OPENCLAUDE_CONFIG_DIR = '/tmp/oc-config-only'
|
||||
const { getClaudeConfigHomeDir } = await importFreshEnvUtils()
|
||||
|
||||
expect(getClaudeConfigHomeDir()).toBe('/tmp/oc-config-only')
|
||||
})
|
||||
|
||||
test('OPENCLAUDE_CONFIG_DIR wins when both env vars are set with different values', async () => {
|
||||
process.env.OPENCLAUDE_CONFIG_DIR = '/tmp/oc-wins'
|
||||
process.env.CLAUDE_CONFIG_DIR = '/tmp/legacy-loses'
|
||||
const { getClaudeConfigHomeDir } = await importFreshEnvUtils()
|
||||
|
||||
expect(getClaudeConfigHomeDir()).toBe('/tmp/oc-wins')
|
||||
})
|
||||
|
||||
test('CLAUDE_CONFIG_DIR is still honored when OPENCLAUDE_CONFIG_DIR is unset', async () => {
|
||||
delete process.env.OPENCLAUDE_CONFIG_DIR
|
||||
process.env.CLAUDE_CONFIG_DIR = '/tmp/legacy-only'
|
||||
const { getClaudeConfigHomeDir } = await importFreshEnvUtils()
|
||||
|
||||
expect(getClaudeConfigHomeDir()).toBe('/tmp/legacy-only')
|
||||
})
|
||||
|
||||
test('empty OPENCLAUDE_CONFIG_DIR falls through to CLAUDE_CONFIG_DIR', async () => {
|
||||
process.env.OPENCLAUDE_CONFIG_DIR = ''
|
||||
process.env.CLAUDE_CONFIG_DIR = '/tmp/legacy-fallback'
|
||||
const { getClaudeConfigHomeDir } = await importFreshEnvUtils()
|
||||
|
||||
expect(getClaudeConfigHomeDir()).toBe('/tmp/legacy-fallback')
|
||||
})
|
||||
|
||||
test('resolveConfigDirEnv prefers OPENCLAUDE over CLAUDE and warns on conflict', async () => {
|
||||
const { resolveConfigDirEnv, __resetConfigDirEnvWarningForTesting } =
|
||||
await importFreshEnvUtils()
|
||||
__resetConfigDirEnvWarningForTesting()
|
||||
|
||||
const warnings: string[] = []
|
||||
const result = resolveConfigDirEnv({
|
||||
openClaudeConfigDir: '/a',
|
||||
legacyConfigDir: '/b',
|
||||
warn: m => warnings.push(m),
|
||||
})
|
||||
|
||||
expect(result).toBe('/a')
|
||||
expect(warnings.length).toBe(1)
|
||||
expect(warnings[0]).toContain('OPENCLAUDE_CONFIG_DIR=/a')
|
||||
expect(warnings[0]).toContain('CLAUDE_CONFIG_DIR=/b')
|
||||
})
|
||||
|
||||
test('resolveConfigDirEnv does not warn when both env vars agree', async () => {
|
||||
const { resolveConfigDirEnv, __resetConfigDirEnvWarningForTesting } =
|
||||
await importFreshEnvUtils()
|
||||
__resetConfigDirEnvWarningForTesting()
|
||||
|
||||
const warnings: string[] = []
|
||||
const result = resolveConfigDirEnv({
|
||||
openClaudeConfigDir: '/same',
|
||||
legacyConfigDir: '/same',
|
||||
warn: m => warnings.push(m),
|
||||
})
|
||||
|
||||
expect(result).toBe('/same')
|
||||
expect(warnings).toEqual([])
|
||||
})
|
||||
|
||||
test('resolveConfigDirEnv returns undefined when neither env var is set', async () => {
|
||||
const { resolveConfigDirEnv } = await importFreshEnvUtils()
|
||||
|
||||
expect(
|
||||
resolveConfigDirEnv({
|
||||
openClaudeConfigDir: undefined,
|
||||
legacyConfigDir: undefined,
|
||||
}),
|
||||
).toBeUndefined()
|
||||
})
|
||||
|
||||
test('project and local settings paths use .openclaude', async () => {
|
||||
const { getRelativeSettingsFilePathForSource } = await importFreshSettings()
|
||||
|
||||
|
||||
104
src/utils/plugins/gitEnv.test.ts
Normal file
104
src/utils/plugins/gitEnv.test.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
__resetGitEnvWarningForTesting,
|
||||
buildGitChildEnv,
|
||||
sanitizeEnvForGit,
|
||||
} from './gitEnv.js'
|
||||
|
||||
describe('sanitizeEnvForGit', () => {
|
||||
test('drops values containing LF', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
BAD_NEWLINE: 'line1\nline2',
|
||||
})
|
||||
expect(result.env).toEqual({ GOOD: 'value' })
|
||||
expect(result.dropped).toEqual(['BAD_NEWLINE'])
|
||||
})
|
||||
|
||||
test('drops values containing CR', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
BAD_CR: 'value\r',
|
||||
})
|
||||
expect(result.dropped).toEqual(['BAD_CR'])
|
||||
})
|
||||
|
||||
test('drops values containing NUL', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
BAD_NUL: 'a\0b',
|
||||
})
|
||||
expect(result.dropped).toEqual(['BAD_NUL'])
|
||||
})
|
||||
|
||||
test('drops keys whose name itself contains a control character', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
'BAD\nKEY': 'safe-value',
|
||||
GOOD: 'value',
|
||||
})
|
||||
expect(result.env).toEqual({ GOOD: 'value' })
|
||||
expect(result.dropped).toEqual(['BAD\nKEY'])
|
||||
})
|
||||
|
||||
test('skips entries explicitly set to undefined without listing them as dropped', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
MAYBE: undefined,
|
||||
})
|
||||
expect(result.env).toEqual({ GOOD: 'value' })
|
||||
expect(result.dropped).toEqual([])
|
||||
})
|
||||
|
||||
test('returns input unchanged when nothing is unsafe', () => {
|
||||
const env = { PATH: '/usr/bin:/bin', HOME: '/home/user', GIT_TERMINAL_PROMPT: '0' }
|
||||
const result = sanitizeEnvForGit(env)
|
||||
expect(result.env).toEqual(env)
|
||||
expect(result.dropped).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildGitChildEnv', () => {
|
||||
const ORIGINAL_BAD_KEY = 'OPENCLAUDE_TEST_BAD_ENV_FOR_GIT'
|
||||
let originalValue: string | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
__resetGitEnvWarningForTesting()
|
||||
originalValue = process.env[ORIGINAL_BAD_KEY]
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (originalValue === undefined) {
|
||||
delete process.env[ORIGINAL_BAD_KEY]
|
||||
} else {
|
||||
process.env[ORIGINAL_BAD_KEY] = originalValue
|
||||
}
|
||||
})
|
||||
|
||||
test('always sets the no-prompt overrides', () => {
|
||||
const env = buildGitChildEnv()
|
||||
expect(env.GIT_TERMINAL_PROMPT).toBe('0')
|
||||
expect(env.GIT_ASKPASS).toBe('')
|
||||
})
|
||||
|
||||
test('drops process.env values containing control characters (issue #751)', () => {
|
||||
process.env[ORIGINAL_BAD_KEY] = 'paste-with-newline\n'
|
||||
const env = buildGitChildEnv()
|
||||
expect(env[ORIGINAL_BAD_KEY]).toBeUndefined()
|
||||
expect(env.GIT_TERMINAL_PROMPT).toBe('0')
|
||||
})
|
||||
|
||||
test('caller extras override process.env and the no-prompt defaults', () => {
|
||||
const env = buildGitChildEnv({
|
||||
GIT_TERMINAL_PROMPT: '1',
|
||||
CUSTOM_KEY: 'custom-value',
|
||||
})
|
||||
expect(env.GIT_TERMINAL_PROMPT).toBe('1')
|
||||
expect(env.CUSTOM_KEY).toBe('custom-value')
|
||||
})
|
||||
|
||||
test('caller-provided unsafe extras are also dropped', () => {
|
||||
const env = buildGitChildEnv({ EXTRA_BAD: 'a\rb' })
|
||||
expect(env.EXTRA_BAD).toBeUndefined()
|
||||
})
|
||||
})
|
||||
70
src/utils/plugins/gitEnv.ts
Normal file
70
src/utils/plugins/gitEnv.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { logForDebugging } from '../debug.js'
|
||||
|
||||
/**
|
||||
* Git 2.30+ refuses to start when any environment value contains a NUL,
|
||||
* CR, or LF character ("Unsafe environment: control characters are not
|
||||
* allowed in values"). User shells frequently leak such values — a
|
||||
* copy-pasted API key with a trailing newline, or a terminal-set
|
||||
* variable with embedded escape sequences — which would otherwise break
|
||||
* every plugin clone or pull. We drop offending entries before forwarding
|
||||
* the environment to git.
|
||||
*/
|
||||
const GIT_UNSAFE_VALUE_RE = /[\0\r\n]/
|
||||
|
||||
const GIT_NO_PROMPT_ENV = {
|
||||
GIT_TERMINAL_PROMPT: '0', // Prevent terminal credential prompts
|
||||
GIT_ASKPASS: '', // Disable askpass GUI programs
|
||||
}
|
||||
|
||||
let warnedAboutDroppedEnvKeys = false
|
||||
|
||||
/**
|
||||
* Returns a copy of `env` with any entries whose key OR value contains
|
||||
* a NUL/CR/LF removed. The list of dropped key names is returned so
|
||||
* callers can log it without exposing the (possibly secret) values.
|
||||
*/
|
||||
export function sanitizeEnvForGit(
|
||||
env: NodeJS.ProcessEnv,
|
||||
): { env: NodeJS.ProcessEnv; dropped: string[] } {
|
||||
const sanitized: NodeJS.ProcessEnv = {}
|
||||
const dropped: string[] = []
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (value === undefined) continue
|
||||
if (GIT_UNSAFE_VALUE_RE.test(key) || GIT_UNSAFE_VALUE_RE.test(value)) {
|
||||
dropped.push(key)
|
||||
continue
|
||||
}
|
||||
sanitized[key] = value
|
||||
}
|
||||
return { env: sanitized, dropped }
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the environment object passed to a git child process. Merges
|
||||
* `process.env` with the no-prompt overrides and any caller extras,
|
||||
* then strips entries that would trigger git's unsafe-value check. The
|
||||
* first batch of dropped key names is logged once per process so the
|
||||
* user can clean them up in their shell.
|
||||
*/
|
||||
export function buildGitChildEnv(
|
||||
extras?: NodeJS.ProcessEnv,
|
||||
): NodeJS.ProcessEnv {
|
||||
const merged = { ...process.env, ...GIT_NO_PROMPT_ENV, ...(extras ?? {}) }
|
||||
const { env, dropped } = sanitizeEnvForGit(merged)
|
||||
if (dropped.length > 0 && !warnedAboutDroppedEnvKeys) {
|
||||
warnedAboutDroppedEnvKeys = true
|
||||
logForDebugging(
|
||||
`git child env: dropped ${dropped.length} key(s) containing control characters: ${dropped.join(', ')}. Git 2.30+ rejects them; clean these up in your shell to forward them to git.`,
|
||||
{ level: 'warn' },
|
||||
)
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-only escape hatch that resets the once-per-process warning flag
|
||||
* so unit tests can exercise the warning path repeatedly.
|
||||
*/
|
||||
export function __resetGitEnvWarningForTesting(): void {
|
||||
warnedAboutDroppedEnvKeys = false
|
||||
}
|
||||
@@ -53,6 +53,7 @@ import {
|
||||
getAddDirExtraMarketplaces,
|
||||
} from './addDirPluginSettings.js'
|
||||
import { markPluginVersionOrphaned } from './cacheUtils.js'
|
||||
import { buildGitChildEnv } from './gitEnv.js'
|
||||
import { classifyFetchError, logPluginFetch } from './fetchTelemetry.js'
|
||||
import { removeAllPluginsForMarketplace } from './installedPluginsManager.js'
|
||||
import {
|
||||
@@ -506,11 +507,6 @@ function seedDirFor(installLocation: string): string | undefined {
|
||||
* Provides helpful error messages for common failure scenarios.
|
||||
* If a ref is specified, fetches and checks out that specific branch or tag.
|
||||
*/
|
||||
// Environment variables to prevent git from prompting for credentials
|
||||
const GIT_NO_PROMPT_ENV = {
|
||||
GIT_TERMINAL_PROMPT: '0', // Prevent terminal credential prompts
|
||||
GIT_ASKPASS: '', // Disable askpass GUI programs
|
||||
}
|
||||
|
||||
const DEFAULT_PLUGIN_GIT_TIMEOUT_MS = 120 * 1000
|
||||
|
||||
@@ -531,7 +527,7 @@ export async function gitPull(
|
||||
options?: { disableCredentialHelper?: boolean; sparsePaths?: string[] },
|
||||
): Promise<{ code: number; stderr: string }> {
|
||||
logForDebugging(`git pull: cwd=${cwd} ref=${ref ?? 'default'}`)
|
||||
const env = { ...process.env, ...GIT_NO_PROMPT_ENV }
|
||||
const env = buildGitChildEnv()
|
||||
const baseArgs = ['-c', 'core.hooksPath=/dev/null']
|
||||
const credentialArgs = options?.disableCredentialHelper
|
||||
? ['-c', 'credential.helper=']
|
||||
@@ -844,7 +840,7 @@ export async function gitClone(
|
||||
const result = await execFileNoThrowWithCwd(gitExe(), args, {
|
||||
timeout: timeoutMs,
|
||||
stdin: 'ignore',
|
||||
env: { ...process.env, ...GIT_NO_PROMPT_ENV },
|
||||
env: buildGitChildEnv(),
|
||||
})
|
||||
|
||||
// Scrub credentials from execa's error/stderr fields before any logging or
|
||||
@@ -870,7 +866,7 @@ export async function gitClone(
|
||||
cwd: targetPath,
|
||||
timeout: timeoutMs,
|
||||
stdin: 'ignore',
|
||||
env: { ...process.env, ...GIT_NO_PROMPT_ENV },
|
||||
env: buildGitChildEnv(),
|
||||
},
|
||||
)
|
||||
if (sparseResult.code !== 0) {
|
||||
@@ -889,7 +885,7 @@ export async function gitClone(
|
||||
cwd: targetPath,
|
||||
timeout: timeoutMs,
|
||||
stdin: 'ignore',
|
||||
env: { ...process.env, ...GIT_NO_PROMPT_ENV },
|
||||
env: buildGitChildEnv(),
|
||||
},
|
||||
)
|
||||
if (checkoutResult.code !== 0) {
|
||||
@@ -1040,7 +1036,7 @@ export async function reconcileSparseCheckout(
|
||||
cwd: string,
|
||||
sparsePaths: string[] | undefined,
|
||||
): Promise<{ code: number; stderr: string }> {
|
||||
const env = { ...process.env, ...GIT_NO_PROMPT_ENV }
|
||||
const env = buildGitChildEnv()
|
||||
|
||||
if (sparsePaths && sparsePaths.length > 0) {
|
||||
return execFileNoThrowWithCwd(
|
||||
|
||||
@@ -87,6 +87,7 @@ import { getAddDirEnabledPlugins } from './addDirPluginSettings.js'
|
||||
import { verifyAndDemote } from './dependencyResolver.js'
|
||||
import { classifyFetchError, logPluginFetch } from './fetchTelemetry.js'
|
||||
import { checkGitAvailable } from './gitAvailability.js'
|
||||
import { buildGitChildEnv } from './gitEnv.js'
|
||||
import { getInMemoryInstalledPlugins } from './installedPluginsManager.js'
|
||||
import { getManagedPluginNames } from './managedPlugins.js'
|
||||
import {
|
||||
@@ -560,7 +561,9 @@ export async function gitClone(
|
||||
args.push(gitUrl, targetPath)
|
||||
|
||||
const cloneStarted = performance.now()
|
||||
const cloneResult = await execFileNoThrow(gitExe(), args)
|
||||
const cloneResult = await execFileNoThrow(gitExe(), args, {
|
||||
env: buildGitChildEnv(),
|
||||
})
|
||||
|
||||
if (cloneResult.code !== 0) {
|
||||
logPluginFetch(
|
||||
@@ -579,7 +582,7 @@ export async function gitClone(
|
||||
const shallowFetchResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--depth', '1', 'origin', sha],
|
||||
{ cwd: targetPath },
|
||||
{ cwd: targetPath, env: buildGitChildEnv() },
|
||||
)
|
||||
|
||||
if (shallowFetchResult.code !== 0) {
|
||||
@@ -591,7 +594,7 @@ export async function gitClone(
|
||||
const unshallowResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--unshallow'],
|
||||
{ cwd: targetPath },
|
||||
{ cwd: targetPath, env: buildGitChildEnv() },
|
||||
)
|
||||
|
||||
if (unshallowResult.code !== 0) {
|
||||
@@ -612,7 +615,7 @@ export async function gitClone(
|
||||
const checkoutResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['checkout', sha],
|
||||
{ cwd: targetPath },
|
||||
{ cwd: targetPath, env: buildGitChildEnv() },
|
||||
)
|
||||
|
||||
if (checkoutResult.code !== 0) {
|
||||
@@ -745,7 +748,9 @@ export async function installFromGitSubdir(
|
||||
}
|
||||
cloneArgs.push(gitUrl, cloneDir)
|
||||
|
||||
const cloneResult = await execFileNoThrow(gitExe(), cloneArgs)
|
||||
const cloneResult = await execFileNoThrow(gitExe(), cloneArgs, {
|
||||
env: buildGitChildEnv(),
|
||||
})
|
||||
if (cloneResult.code !== 0) {
|
||||
throw new Error(
|
||||
`Failed to clone repository for git-subdir source: ${cloneResult.stderr}`,
|
||||
@@ -756,7 +761,7 @@ export async function installFromGitSubdir(
|
||||
const sparseResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['sparse-checkout', 'set', '--cone', '--', subdirPath],
|
||||
{ cwd: cloneDir },
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
)
|
||||
if (sparseResult.code !== 0) {
|
||||
throw new Error(
|
||||
@@ -775,7 +780,7 @@ export async function installFromGitSubdir(
|
||||
const fetchSha = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--depth', '1', 'origin', sha],
|
||||
{ cwd: cloneDir },
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
)
|
||||
if (fetchSha.code !== 0) {
|
||||
logForDebugging(
|
||||
@@ -784,7 +789,7 @@ export async function installFromGitSubdir(
|
||||
const unshallow = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--unshallow'],
|
||||
{ cwd: cloneDir },
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
)
|
||||
if (unshallow.code !== 0) {
|
||||
throw new Error(`Failed to fetch commit ${sha}: ${unshallow.stderr}`)
|
||||
@@ -793,7 +798,7 @@ export async function installFromGitSubdir(
|
||||
const checkout = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['checkout', sha],
|
||||
{ cwd: cloneDir },
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
)
|
||||
if (checkout.code !== 0) {
|
||||
throw new Error(`Failed to checkout commit ${sha}: ${checkout.stderr}`)
|
||||
@@ -808,9 +813,11 @@ export async function installFromGitSubdir(
|
||||
const [checkout, revParse] = await Promise.all([
|
||||
execFileNoThrowWithCwd(gitExe(), ['checkout', 'HEAD'], {
|
||||
cwd: cloneDir,
|
||||
env: buildGitChildEnv(),
|
||||
}),
|
||||
execFileNoThrowWithCwd(gitExe(), ['rev-parse', 'HEAD'], {
|
||||
cwd: cloneDir,
|
||||
env: buildGitChildEnv(),
|
||||
}),
|
||||
])
|
||||
if (checkout.code !== 0) {
|
||||
|
||||
@@ -34,8 +34,7 @@ export function getSecureStorageServiceName(
|
||||
serviceSuffix: string = '',
|
||||
): string {
|
||||
const configDir = getClaudeConfigHomeDir()
|
||||
const isDefaultDir =
|
||||
!process.env.OPENCLAUDE_CONFIG_DIR && !process.env.CLAUDE_CONFIG_DIR
|
||||
const isDefaultDir = !process.env.CLAUDE_CONFIG_DIR
|
||||
|
||||
// Use a hash of the config dir path to create a unique but stable suffix
|
||||
// Only add suffix for non-default directories to maintain backwards compatibility
|
||||
|
||||
@@ -117,8 +117,7 @@ const TEAMMATE_ENV_VARS = [
|
||||
'MISTRAL_BASE_URL',
|
||||
// Custom API endpoint
|
||||
'ANTHROPIC_BASE_URL',
|
||||
// Config directory override (preferred name + legacy alias)
|
||||
'OPENCLAUDE_CONFIG_DIR',
|
||||
// Config directory override
|
||||
'CLAUDE_CONFIG_DIR',
|
||||
// CCR marker — teammates need this for CCR-aware code paths. Auth finds
|
||||
// its own way via /home/claude/.claude/remote/.oauth_token regardless;
|
||||
|
||||
Reference in New Issue
Block a user