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

No coverage files found for Node v5.8.0 and NPM v3.7.3 #190

Closed
arrowrowe opened this issue Mar 11, 2016 · 32 comments
Closed

No coverage files found for Node v5.8.0 and NPM v3.7.3 #190

arrowrowe opened this issue Mar 11, 2016 · 32 comments

Comments

@arrowrowe
Copy link

UPDATE: See @addaleax's analysis here.


See these Travis logs for details:

ERROR: No coverage files found.

This happens only using Node v5.8.0 and NPM v3.7.3 together.


UPDATE: Thanks to @novemberborn's response and @thangngoc89's suggestion in MoOx/phenomic#296, I am working around telling Travis to install latest NPM (i.e. 3.8.1). Below is added to .travis.yml.

before_install:
  - npm install -g npm@latest
@novemberborn
Copy link
Contributor

@arrowrowe I cloned https://github.com/arrowrowe/romi and installed it locally. npm test ran fine:

-----------|----------|----------|----------|----------|----------------|
File       |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-----------|----------|----------|----------|----------|----------------|
 romi/     |    94.34 |      100 |      100 |      100 |                |
  index.js |    94.34 |      100 |      100 |      100 |                |
-----------|----------|----------|----------|----------|----------------|
All files  |    94.34 |      100 |      100 |      100 |                |
-----------|----------|----------|----------|----------|----------------|

This is on OS X, npm 3.8.1.

Can you reproduce this outside of Travis?

@sarbbottam
Copy link

Works fine for me in v5.8.0

@arrowrowe
Copy link
Author

Thanks for responding! I will retry it later to confirm.

@arrowrowe
Copy link
Author

Failed on Ubuntu 14.04.1, using Node v5.8.0 and NPM v3.7.3, as the log below shows. (No need to paste it in fact. It is same with the Travis log.)

   3 passed

----------|----------|----------|----------|----------|----------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
----------|----------|----------|----------|----------|----------------|
All files |      100 |      100 |      100 |      100 |                |
----------|----------|----------|----------|----------|----------------|

ERROR: No coverage files found.
npm ERR! Test failed.  See above for more details.

However, npm test does run fine after I update to NPM v3.8.1, (the version @novemberborn uses,) remove node_modules and npm i again. So, is this problem happening only using Node v5.8.0 and NPM v3.7.3?........ Or was I making a mistake somewhere?...

Not sure what causes this.........

@arrowrowe arrowrowe changed the title No coverage files found for Node v5.8.0 No coverage files found for Node v5.8.0 and NPM v3.7.3 Mar 12, 2016
@novemberborn
Copy link
Contributor

So, is this problem happening only using Node v5.8.0 and NPM v3.7.3?........ Or was I making a mistake somewhere?...

If you remove node_modules and reinstall under npm 3.7.3, does it work then?

@arrowrowe
Copy link
Author

@novemberborn I suppose not, as Travis's fresh install (Node v5.8.0 and NPM v3.7.3) fails. I am confirming it now. Will update later.


upd: It works on my Ubuntu............... Seriously confused now. I am restarting Travis's build. Will update later.


upd: The Travis build with Node v5.8.0 and NPM v3.7.3 still fails. I am confirming all this on my Linux server, in case anything local effects the result. Will update later.


upd: It fails on my Linux server, using Node v5.8.0 and NPM v3.7.3. Confirmed. The thing is:

  • Install Node v5.8.0. It comes with NPM v3.7.3. Run npm install. Now npm test fails.
  • Now npm i -g npm@latest to update NPM to v3.8.1. (NOTE: don't remove node_modules.) Now npm test passes.
  • Now npm i -g npm@3.7.3. (NOTE: don't remove node_modules.) Now npm test passes.
  • Uninstall Node v5.8.0 and reinstall it again. It comes with NPM v3.7.3. Now npm test fails again.

@thangngoc89
Copy link

@arrowrowe woa. Thanks for you efforts. So much trouble with npm.

@bcoe
Copy link
Member

bcoe commented Mar 31, 2016

@arrowrowe this is a really interesting bug! I'd be interested to diff npm@3.8.1 vs. npm@3.7.3 -- I wonder if we touched anything in the script execution logic.

@addaleax
Copy link
Member

I think I understand this.

This has nothing to do with npm versions at all. [Update: Okay, at least not the ones mentioned above. See below.] As far as I can tell, it is because the Node.js distributions have the shebang at the start of npm-cli.js replaced with a (relative) reference to the Node.js executable.
This throws spawn-wrap off, though: It relies on being able to tell that Node.js is invoked (e.g. because the command name that should be executed is node) or that adding a directory containing a wrapper script to the PATH environment variable will suffice. Since the command name is npm, not node, and the Node.js interpreter path is hardcoded in the npm-cli.js, spawn-wrap cannot attach its handler code anywhere inside the npm process.
This could even be fine, because PATH contains the spawn-wrap wrapper, so that one should get executed when a Node.js script with #!/usr/bin/env node (like mocha) is invoked, right? Well, npm likes to make its own changes to PATH, and sets the directory of the currently running Node.js executable with a higher priority than everything else in PATH. So again, no chance for spawn-wrap to attach itself. [Update: Thanks to #211, I looked up the change in npm where this was introduced (commit, PR), i.e. npm versions starting from v3.7.0 are affected.]

Re-installing npm solved the problem because npm’s copy of npm-cli.js contains no modified shebang, so the “right” wrapper script gets invoked. Another workaround might be running nyc node $(which npm) test or something like that.

(You can see the difference between the installed npm-cli.js files here.)

I don’t know whether this is fixable without either some special handing of npm commands in spawn-wrap or changes to the npm cli itself.

@arrowrowe
Copy link
Author

Thanks a lot @addaleax! I will leave the right to close this issue to the owner @bcoe.

chrissearle added a commit to chrissearle/fredagsmoro_react that referenced this issue Mar 31, 2016
@addaleax
Copy link
Member

I think I’d be willing to write a patch for spawn-wrap which adds special handling for npm, if there’s a chance it gets landed. @bcoe, what do you think? izs seems to have abandoned that module, but given that you’re a member of npm and tapjs, I imagine you can assess the situation better than I do?

@bcoe
Copy link
Member

bcoe commented Mar 31, 2016

@addaleax wonderful find, yes please submit a patch to spawn-wrap and I can help land it.

@bcoe
Copy link
Member

bcoe commented Mar 31, 2016

@addaleax if I'm reading this correctly, does the issue arise when the platform is detected as PORTABLE?

@addaleax
Copy link
Member

@bcoe The issues arises either way. PORTABLE is set for generating the Node.js binary distribution tarballs, and is not set when running their make install in a source tree (I have tested this with both configurations). In any case the node binary is invoked using its full path, and that moves PATH out of the way.

addaleax added a commit to addaleax/spawn-wrap that referenced this issue Mar 31, 2016
As laid out in istanbuljs/nyc#190, spawn-wrap’ing `npm` does currently
not work when using the `npm` binary that comes bundled with Node.js.

This adds special handler code for the case that `npm` is the
program that should be executed, looking for the `npm` executable
in PATH and invoking the shim with it as an argument.
addaleax added a commit to addaleax/spawn-wrap that referenced this issue Mar 31, 2016
As laid out in istanbuljs/nyc#190, spawn-wrap’ing `npm` does currently
not work when using the `npm` binary that comes bundled with Node.js.

This adds special handler code for the case that `npm` is the
program that should be executed, looking for the `npm` executable
in PATH and invoking the shim with it as an argument.
arrowrowe added a commit to arrowrowe/textlint-rule-editorconfig that referenced this issue Apr 1, 2016
arrowrowe added a commit to arrowrowe/textlint-rule-editorconfig that referenced this issue Apr 1, 2016
@sarbbottam
Copy link

There is a work around to this, please refer this comment at #211, instead of npm test, if the command aliased to npm test is used, it works fine.

@bcoe
Copy link
Member

bcoe commented Apr 3, 2016

@addaleax what's a good email to use for you, I'd love to get you into our slack so we can debug this issue.

@addaleax
Copy link
Member

addaleax commented Apr 3, 2016

@bcoe Seen? Would like to delete the comment with my raw email address if that’s okay. 😄

addaleax added a commit to addaleax/spawn-wrap that referenced this issue Apr 4, 2016
As laid out in istanbuljs/nyc#190, spawn-wrap’ing `npm` does currently
not work when using the `npm` binary that comes bundled with Node.js.

This adds special handler code for the case that `npm` is the
program that should be executed, looking for the `npm` executable
in PATH using `which` and invoking the shim with it as an argument.
@arrowrowe
Copy link
Author

@jamestalmage thanks for the advice! It does benefit shortening scripts. I didn't notice the fact that my tortuous usage put npm run lint under coverage as well :(. And making scripts recursively call themselves is no more than a bad personal habit, which I will remember to avoid later on. The direct usage of AVA and XO in command line is cool; it is just sometimes there are different test suits across projects, and npm test always works. Thanks for your advice again.

@jamestalmage
Copy link
Member

and npm test always works

Indeed, that's a good reason to use it. If you consistently use test:only and test:easy for all projects in your organization - that is good reason to include those scripts in package.json as well. It serves as documentation on the sort of build commands that can be run. I was just pointing out that there are shortcuts which should run a little faster.

@addaleax
Copy link
Member

addaleax commented Apr 4, 2016

And making scripts recursively call themselves is no more than a bad personal habit, which I will remember to avoid later on.

I think it’s quite okay. Either way, the issue with running nyc + recursive npm scripts should be fixed soon, too.

@jamestalmage
Copy link
Member

I think it’s quite okay.

Agreed - it's not a mistake to do so, just a bit verbose in this particular case.

@novemberborn
Copy link
Contributor

You almost certainly don't want npm run lint being run with coverage

@jamestalmage I doubt this has any adverse effects though. The linter code wouldn't be instrumented and it would use the filesystem to access the code.

@jamestalmage
Copy link
Member

I doubt this has any adverse effects though.

Wrapping with spawn-wrap and foreground-child have their cost. The use of append-transform has (minimally) adverse affects on require time. The affect should be minimal however.

isaacs pushed a commit to istanbuljs/spawn-wrap that referenced this issue Apr 5, 2016
As laid out in istanbuljs/nyc#190, spawn-wrap’ing `npm` does currently
not work when using the `npm` binary that comes bundled with Node.js.

This adds special handler code for the case that `npm` is the
program that should be executed, looking for the `npm` executable
in PATH using `which` and invoking the shim with it as an argument.
@bcoe
Copy link
Member

bcoe commented Apr 5, 2016

@addaleax @arrowrowe can we close this at this point? If you run:

npm i nyc@next

We've landed various fixes to the 5.8.0 bug.

@arrowrowe
Copy link
Author

@bcoe good to me now! 💯

@MoOx
Copy link

MoOx commented Apr 5, 2016

Maybe close when you cut a stable release? (This helps people tracking the issue to now when it's "stable").

addaleax added a commit to addaleax/nyc that referenced this issue Apr 5, 2016
Adds tests for checking that `nyc npm test` works,
one for when the npm `test` script directly refers to the
JS script and one for when npm runs nested lifecycle scripts.
This is a regression test for istanbuljs#190.
@bcoe
Copy link
Member

bcoe commented Apr 6, 2016

nyc@6.2.1 is released.

@bcoe bcoe closed this as completed Apr 6, 2016
addaleax added a commit to addaleax/nyc that referenced this issue Apr 7, 2016
This also belongs to istanbuljs#190, but the new tests include actual
fake “npm” executables with both absolute shebangs and the
twisted shebang that comes with current Node.js binary distribution
tarballs.
addaleax added a commit to addaleax/nyc that referenced this issue Apr 7, 2016
This also belongs to istanbuljs#190, but the new tests include actual
fake “npm” executables with both absolute shebangs and the
twisted shebang that comes with current Node.js binary distribution
tarballs.
addaleax added a commit to addaleax/nyc that referenced this issue Apr 7, 2016
This also belongs to istanbuljs#190, but the new tests include actual
fake “npm” executables with both absolute shebangs and the
twisted shebang that comes with current Node.js binary distribution
tarballs.
addaleax added a commit to addaleax/nyc that referenced this issue Apr 8, 2016
Adds tests for checking that `nyc npm test` works,
one for when the npm `test` script directly refers to the
JS script and one for when npm runs nested lifecycle scripts.
This is a regression test for istanbuljs#190.
addaleax added a commit to addaleax/nyc that referenced this issue Apr 8, 2016
This also belongs to istanbuljs#190, but the new tests include actual
fake “npm” executables with both absolute shebangs and the
twisted shebang that comes with current Node.js binary distribution
tarballs.
chrissearle added a commit to chrissearle/fredagsmoro_react that referenced this issue Apr 18, 2016
@ghost ghost mentioned this issue Jul 8, 2016
addaleax added a commit to addaleax/spawn-wrap that referenced this issue Jul 9, 2016
Fixes a variant of istanbuljs/nyc#190 for
Windows when the `npm.cmd` shim is invoked from the shell
(i.e. `cmd /s`).

Fixes: istanbuljs/nyc#300
addaleax added a commit to addaleax/spawn-wrap that referenced this issue Jul 9, 2016
Fixes a variant of istanbuljs/nyc#190 for
Windows when the `npm.cmd` shim is invoked from the shell
(i.e. `cmd /s`).

Fixes: istanbuljs/nyc#300
addaleax added a commit to addaleax/spawn-wrap that referenced this issue Jul 9, 2016
Fixes a variant of istanbuljs/nyc#190 for
Windows when the `npm.cmd` shim is invoked from the shell
(i.e. `cmd /s`).

Fixes: istanbuljs/nyc#300
addaleax added a commit to addaleax/spawn-wrap that referenced this issue Jul 9, 2016
Fixes a variant of istanbuljs/nyc#190 for
Windows when the `npm.cmd` shim is invoked from the shell
(i.e. `cmd /s /c`).

Fixes: istanbuljs/nyc#300
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

8 participants