From f00d5979c595cfeaffd463146314b61347947150 Mon Sep 17 00:00:00 2001 From: HipsterBrown Date: Mon, 30 Dec 2024 13:04:30 -0500 Subject: [PATCH 1/2] fix(mcpack): check manifest include value before resolving --- tools/mcpack.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/mcpack.js b/tools/mcpack.js index 91813a3f1..da6967883 100644 --- a/tools/mcpack.js +++ b/tools/mcpack.js @@ -1043,10 +1043,12 @@ export default class extends TOOL { } includeManifest(include, from, directory) { this.currentDirectory = directory; - let path = this.resolveFilePath(this.resolveVariable(include)); - if (!path) - throw new Error("'" + include + "': manifest not found!"); - this.parseManifest(path, from); + if ("string" == typeof include) { + let path = this.resolveFilePath(this.resolveVariable(include)); + if (!path) + throw new Error("'" + include + "': manifest not found!"); + this.parseManifest(path, from); + } } mapBuiltins(builtins) { const map = new Map; From 17e939ea2193a130929728d451b96283a0bb0558 Mon Sep 17 00:00:00 2001 From: HipsterBrown Date: Mon, 13 Apr 2026 23:43:18 -0400 Subject: [PATCH 2/2] fix(tools): prevent build vars from overriding env vars --- tools/mcmanifest.js | 10 +++++++++- tools/mcpack.js | 14 ++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/mcmanifest.js b/tools/mcmanifest.js index 6ef9e4668..5e8e55128 100644 --- a/tools/mcmanifest.js +++ b/tools/mcmanifest.js @@ -2989,7 +2989,15 @@ export class Tool extends TOOL { this.environment[name] = `${this.environment[name]} ${value}`; } else { - if (typeof value == "string") { + // If the shell already provides this variable and it hasn't been set + // by the tool internally, prefer the shell value over the manifest + // default so user-configured paths (e.g. xs-dev install locations) + // are not overridden by the manifest's default assumptions. + const shellValue = this.getenv(name); + if (shellValue !== undefined && !(name in this.environment)) { + value = shellValue; + } + else if (typeof value == "string") { const dotSlash = "." + this.slash; value = this.resolveVariable(value); if (value.startsWith(dotSlash)) { diff --git a/tools/mcpack.js b/tools/mcpack.js index da6967883..e00c7fbf5 100644 --- a/tools/mcpack.js +++ b/tools/mcpack.js @@ -1082,7 +1082,15 @@ export default class extends TOOL { if (properties) { for (let name in properties) { let value = properties[name]; - if (typeof value == "string") { + // If the shell already provides this variable and it hasn't been set + // by the tool internally, prefer the shell value over the manifest + // default so user-configured paths (e.g. xs-dev install locations) + // are not overridden by the manifest's default assumptions. + const shellValue = this.getenv(name); + if (shellValue !== undefined && !(name in this.environment)) { + value = shellValue; + } + else if (typeof value == "string") { const dotSlash = "." + this.slash; value = this.resolveVariable(value); if (value.startsWith(dotSlash)) { @@ -1094,10 +1102,8 @@ export default class extends TOOL { value = path + value.slice(1); } } - this.environment[name] = value; } - else - this.environment[name] = value; + this.environment[name] = value; } } }