Skip to content

Commit

Permalink
Calling NPM without the user's shell profile.
Browse files Browse the repository at this point in the history
According to the NPM man page, npm gets its configuration information from 5 separate sources. When npm is launched on a *nix system without the user shell npm skips any configuration in the user's $HOME as well as ignores environment variables that might be set in the user's profile or environment.

This resolves appium#1889 and @ZuhayrMerchant110's issue as well as mine where the project directory prefixing the appium path.
  • Loading branch information
Dakota Carter committed Feb 20, 2024
1 parent 63bcbf5 commit f0ed86a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ private static File findMainScript() {
List<String> cmdLine = System.getProperty("os.name").toLowerCase().contains("win")
// npm is a batch script, so on windows we need to use cmd.exe in order to execute it
? Arrays.asList("cmd.exe", "/c", String.format("\"%s\" root -g", npm.getAbsolutePath()))
: Arrays.asList(npm.getAbsolutePath(), "root", "-g");
//ProcessBuilder doesn't execute a shell, some npm functionality requires the user's shell profile
: Arrays.asList("/bin/sh", "--login", "-c", npm.getAbsolutePath() + " root -g");
ProcessBuilder pb = new ProcessBuilder(cmdLine);
String nodeModulesRoot;
try {
Expand Down

0 comments on commit f0ed86a

Please sign in to comment.