fix pi config dir for non-service users
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -282,11 +282,13 @@ export async function spawnPi(
|
|||||||
const apifyToken = await getApifyToken();
|
const apifyToken = await getApifyToken();
|
||||||
const shellUsername = options?.username ?? toShellUsername('', email);
|
const shellUsername = options?.username ?? toShellUsername('', email);
|
||||||
|
|
||||||
|
const isServiceUser = (options?.username ?? toShellUsername('', email)) === (process.env.USER ?? '');
|
||||||
|
|
||||||
const env: Record<string, string> = {
|
const env: Record<string, string> = {
|
||||||
HOME: homeDir,
|
HOME: homeDir,
|
||||||
OFFICER_USER_HOME: homeDir,
|
OFFICER_USER_HOME: homeDir,
|
||||||
OFFICER_USER_ROOT: join(DATA_PATH, email),
|
OFFICER_USER_ROOT: join(DATA_PATH, email),
|
||||||
PI_CODING_AGENT_DIR: PI_CONFIG_DIR,
|
PI_CODING_AGENT_DIR: isServiceUser ? PI_CONFIG_DIR : join(homeDir, '.pi', 'agent'),
|
||||||
PI_TOOLS_DIRS: toolsDirs,
|
PI_TOOLS_DIRS: toolsDirs,
|
||||||
PI_SEARXNG_URL: searxng.url,
|
PI_SEARXNG_URL: searxng.url,
|
||||||
OFFICER_RESOURCES: buildResourcesEnv(),
|
OFFICER_RESOURCES: buildResourcesEnv(),
|
||||||
@@ -297,8 +299,6 @@ export async function spawnPi(
|
|||||||
...browserRelayEnv,
|
...browserRelayEnv,
|
||||||
};
|
};
|
||||||
|
|
||||||
const isServiceUser = shellUsername === (process.env.USER ?? '');
|
|
||||||
|
|
||||||
// For service user, keep real HOME so Pi finds its config
|
// For service user, keep real HOME so Pi finds its config
|
||||||
if (isServiceUser) {
|
if (isServiceUser) {
|
||||||
env.HOME = process.env.HOME ?? '';
|
env.HOME = process.env.HOME ?? '';
|
||||||
|
|||||||
Reference in New Issue
Block a user