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 91813a3f1..e00c7fbf5 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; @@ -1080,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)) { @@ -1092,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; } } }