Skip to content

Commit e854bfa

Browse files
danbevtargos
authored andcommitted
test: create home for test-npm-install
This test currently fails if run as root: npm ERR! makeDirectory homeless? npm WARN install-dir No description npm WARN install-dir No repository field. npm WARN install-dir No license field. npm ERR! path /root/node/test/.tmp.0/npm-sandbox/home npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall stat npm ERR! enoent ENOENT: no such file or directory, stat '/root/node/test/.tmp.0/npm-sandbox/home' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent assert.js:89 throw new AssertionError(obj); ^ AssertionError [ERR_ASSERTION]: npm install got error code 254 at handleExit (/root/node/test/parallel/test-npm-install.js:60:10) at /root/node/test/common/index.js:371:15 at ChildProcess.exithandler (child_process.js:304:5) at ChildProcess.emit (events.js:203:13) at maybeClose (internal/child_process.js:1028:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) { generatedMessage: false, code: 'ERR_ASSERTION', actual: 254, expected: 0, operator: 'strictEqual' } The home directory will be created as expected by npm in the npmSandbox when run as non-root, but when run as root this directory has to exist. This commit creates the home directory to allow the test to pass also when run as the root user. Refs:https://github.com/npm/cli/blob/ 31718e72cb5a03cee7127fc36843e4b55c868d93/ lib/utils/correct-mkdir.js#L82-L105 PR-URL: #28510 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 13f1393 commit e854bfa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/parallel/test-npm-install.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const tmpdir = require('../common/tmpdir');
1313
tmpdir.refresh();
1414
const npmSandbox = path.join(tmpdir.path, 'npm-sandbox');
1515
fs.mkdirSync(npmSandbox);
16+
const homeDir = path.join(tmpdir.path, 'home');
17+
fs.mkdirSync(homeDir);
1618
const installDir = path.join(tmpdir.path, 'install-dir');
1719
fs.mkdirSync(installDir);
1820

@@ -40,7 +42,7 @@ const env = Object.assign({}, process.env, {
4042
PATH: path.dirname(process.execPath),
4143
NPM_CONFIG_PREFIX: path.join(npmSandbox, 'npm-prefix'),
4244
NPM_CONFIG_TMP: path.join(npmSandbox, 'npm-tmp'),
43-
HOME: path.join(npmSandbox, 'home'),
45+
HOME: homeDir,
4446
});
4547

4648
exec(`${process.execPath} ${npmPath} install`, {

0 commit comments

Comments
 (0)