fix(cli): use imported resolve/sep in hermesGlobalHome (#521)

The function called `path.resolve` and `path.sep` but only named-
imports `resolve` and `sep` from `node:path`. The ReferenceError was
swallowed by the try/catch, so $HERMES_HOME was silently ignored and
profile-scoped installs always landed in ~/.hermes instead of the
active profile. Greptile (P1) and Cursor Bugbot (High) flagged this
on 2026-08-10. Adds 6 regression tests covering default, default-
profile, active-profile, cross-home leakage, the override map
integration, and the full e2e pipeline. Verified by reverting the
fix and observing the relevant tests fail.
This commit is contained in:
digitallamb
2026-08-10 22:47:56 -07:00
parent 5ce4a5c6b5
commit def69e157b
2 changed files with 155 additions and 3 deletions
+5 -3
View File
@@ -102,13 +102,13 @@ function hermesGlobalHome(home) {
const envHome = process.env.HERMES_HOME;
if (envHome) {
try {
const resolvedEnv = path.resolve(envHome);
const resolvedHome = path.resolve(home);
const resolvedEnv = resolve(envHome);
const resolvedHome = resolve(home);
// Honor HERMES_HOME only when it lives under the active home (real
// ~/.hermes or ~/.hermes/profiles/<name>). Cross-home inheritance is
// treated as not-set, so a test running under HOME=/tmp/... doesn't
// pick up the developer's real ~/.hermes.
if (resolvedEnv === resolvedHome || resolvedEnv.startsWith(resolvedHome + path.sep)) {
if (resolvedEnv === resolvedHome || resolvedEnv.startsWith(resolvedHome + sep)) {
return resolvedEnv;
}
} catch {
@@ -2271,6 +2271,8 @@ export {
expectedHookDests,
extractZip,
formatInstallDetectionLines,
hermesGlobalHome,
HOME_SKILLS_DIR_OVERRIDES,
linkProviderSkills,
mergeHookManifests,
migrateUnprefixImpeccable,