fix(cli): figer le PATH d'installation dans l'unit systemd / plist launchd
Un service systemd user / LaunchAgent démarre avec un PATH minimal qui n'inclut pas ~/.local/bin (où vit le binaire `claude`) → resolveClaudeBin (`which claude`) échouait avec « Claude Code CLI not found in PATH ». `arboretum install` fige désormais le PATH de l'environnement d'installation dans l'unit/plist.
This commit is contained in:
@@ -79,6 +79,21 @@ describe('cli install — renderSystemdUnit', () => {
|
||||
expect(unit).toContain('ExecStart="/path with space/node" /s.js');
|
||||
});
|
||||
|
||||
it('fige le PATH d\'installation quand fourni (le service systemd a un PATH minimal)', () => {
|
||||
const unit = renderSystemdUnit({
|
||||
exec: '/usr/bin/node',
|
||||
scriptArgs: ['/s.js'],
|
||||
pathEnv: '/home/me/.local/bin:/usr/bin',
|
||||
});
|
||||
// Doubles quotes systemd : un chemin du PATH peut contenir un espace.
|
||||
expect(unit).toContain('Environment="PATH=/home/me/.local/bin:/usr/bin"');
|
||||
});
|
||||
|
||||
it("n'émet aucune ligne PATH sans pathEnv (rétrocompat)", () => {
|
||||
const unit = renderSystemdUnit({ exec: '/usr/bin/node', scriptArgs: ['/s.js'] });
|
||||
expect(unit).not.toContain('PATH=');
|
||||
});
|
||||
|
||||
it('snapshot du unit pour un jeu de flags fixe', () => {
|
||||
const unit = renderSystemdUnit({
|
||||
exec: '/usr/bin/node',
|
||||
@@ -133,6 +148,19 @@ describe('cli install — renderLaunchAgentPlist', () => {
|
||||
expect(plist).toContain('https://a?b&c=d');
|
||||
expect(plist).not.toContain('b&c=d');
|
||||
});
|
||||
|
||||
it('ajoute la clé PATH dans EnvironmentVariables quand fournie (launchd a un PATH minimal)', () => {
|
||||
const plist = renderLaunchAgentPlist({ ...base, pathEnv: '/Users/me/.local/bin:/usr/bin' });
|
||||
expect(plist).toContain('<key>PATH</key>');
|
||||
expect(plist).toContain('<string>/Users/me/.local/bin:/usr/bin</string>');
|
||||
// Reste dans le dict EnvironmentVariables, juste après NODE_ENV.
|
||||
expect(plist.indexOf('<key>PATH</key>')).toBeGreaterThan(plist.indexOf('<key>NODE_ENV</key>'));
|
||||
});
|
||||
|
||||
it("n'ajoute aucune clé PATH sans pathEnv (rétrocompat)", () => {
|
||||
const plist = renderLaunchAgentPlist(base);
|
||||
expect(plist).not.toContain('<key>PATH</key>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('cli install — xmlEscape', () => {
|
||||
|
||||
Reference in New Issue
Block a user