Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doubt 'test-require-deps-deprecation' ? #17799

Closed
bacriom opened this issue Dec 20, 2017 · 13 comments
Closed

doubt 'test-require-deps-deprecation' ? #17799

bacriom opened this issue Dec 20, 2017 · 13 comments

Comments

@bacriom
Copy link
Contributor

bacriom commented Dec 20, 2017

when I run the tests, the console shows the next error:

=== release test-require-deps-deprecation ===
Path: parallel/test-require-deps-deprecation
assert.js:42
throw new errors.AssertionError(obj);
^

AssertionError [ERR_ASSERTION]: Missing expected exception.
at Object. (/home/ocrisostomo/node/test/parallel/test-require-deps-deprecation.js:43:10)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:577:32)
at tryModuleLoad (module.js:517:12)
at Function.Module._load (module.js:509:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:645:3
Command: out/Release/node /home/ocrisostomo/node/test/parallel/test-require-deps-deprecation.js
Command: out/Release/node /home/ocrisostomo/node/test/parallel/test-require-deps-deprecation.js
[04:09|% 100|+ 2131|- 1]: Done
Makefile:215: recipe for target 'test' failed
make: *** [test] Error 1

so It's normal or is there something that I have to do to run all tests?

@bacriom bacriom changed the title due 'test-require-deps-deprecation' doubt 'test-require-deps-deprecation' Dec 20, 2017
@bacriom bacriom changed the title doubt 'test-require-deps-deprecation' doubt 'test-require-deps-deprecation' ? Dec 20, 2017
@Trott
Copy link
Member

Trott commented Dec 20, 2017

(Never mind my previous (now-deleted) comment.)

@bacriom Looking at #17148, this has been seen previously if you have the NODE_PATH environment variable set to some value that results in acorn being found in the module path. If you were running make test, perhaps try NODE_PATH='' make test?

@bacriom
Copy link
Contributor Author

bacriom commented Dec 21, 2017

thanks, I tried with NODE_PATH='' make test and got the same result.

I have another question, I wrote the next:

for (const m of deps) { try { assert.throws(() => { require(m); }, /^Error: Cannot find module/); } catch (err) {} }

I ran the tests and I got:

/usr/bin/python2.7 tools/test.py --mode=release -J \ async-hooks \ default \ addons addons-napi \ doctool \ known_issues [04:04|% 100|+ 2132|- 0]: Done

so for what reason happens it?

@Trott
Copy link
Member

Trott commented Dec 21, 2017

So, the original problem here is the test is managing to load internal modules that it should not be able to load. This is usually because something somewhere has been configured to look in unusual places to load modules. The most common cause of this is setting NODE_PATH but that's not the only cause. So let's check a few things from your shell/command line:

  • What's the output of echo $NODE_PATH?
  • What's the output of ls $HOME/.node_modules?
  • What's the output of ls $HOME/.node_libraries?
  • What's the output of grep node_prefix config.gypi when run from the project root directory?
  • What's the output of ls node_modules when run from the project root directory?

Thanks for your patience with this!

@bacriom
Copy link
Contributor Author

bacriom commented Dec 21, 2017

ok, The outputs are:

What's the output of echo $NODE_PATH?
empty line

What's the output of ls $HOME/.node_modules?
ls: cannot access '/home/ocrisostomo/.node_modules': No such file or directory

What's the output of ls $HOME/.node_libraries?
ls: cannot access '/home/ocrisostomo/.node_libraries': No such file or directory

What's the output of grep node_prefix config.gypi when run from the project root directory?
grep node_prefix config.gypi

What's the output of ls node_modules when run from the project root directory?
ls: cannot access 'node_modules': No such file or directory

@Trott
Copy link
Member

Trott commented Dec 21, 2017

What's the output of grep node_prefix config.gypi when run from the project root directory?
grep node_prefix config.gypi

That looks like maybe you accidentally pasted the input as the output of the command?

@bacriom
Copy link
Contributor Author

bacriom commented Dec 21, 2017

yes I was wrong, the output is:
'node_prefix': '/usr/local',

@targos
Copy link
Member

targos commented Dec 21, 2017

Maybe you have a node_modules directory that contains one of the deps somewhere between your Node.js clone and / ?

@targos
Copy link
Member

targos commented Dec 21, 2017

Can you try to add console.log(require.resolve(m)); in the test?

@Trott
Copy link
Member

Trott commented Dec 21, 2017

(Can you also confirm that /usr/local/node_modules does not exist?)

@Trott
Copy link
Member

Trott commented Dec 21, 2017

Can you try to add console.log(require.resolve(m)); in the test?

Oh, yeah, that's probably where we should have started with troubleshooting.

@bacriom Since we know it's one or both of two modules, you can (if you want) probably skip trying to add that to the test and instead run these from the command line in the project root directory:

./node -p 'require.resolve("acorn/dist/acorn")'

and

./node -p 'require.resolve("acorn/dist/walk")'

When things work as expected, both of those return errors. However, in your case, if one or both return a string, that string will tell us where the file is that is messing up the test. :-D

@bacriom
Copy link
Contributor Author

bacriom commented Dec 21, 2017

I got the next directory when I ran ./node -p 'require.resolve("acorn/dist/acorn")' :
/home/ocrisostomo/node_modules/acorn/dist/acorn.js

also, I got the same directory to "acorn/dist/walk"

@Trott
Copy link
Member

Trott commented Dec 21, 2017

Cool, so the problem is that acorn is being found in the node_modules in your home directory. If that directory is there by accident (ran npm install something in your home directory one time), you can remove it. If you're using it , or to be safe, you can rename it instead. That should make the test (and make test) pass.

@bacriom
Copy link
Contributor Author

bacriom commented Dec 21, 2017

Thanks @Trott for your help, I'll remove node_modules and run the tests

@bacriom bacriom closed this as completed Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants