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

v10.0.0-rc.0 + npm emitting Buffer deprecation warnings #20160

Closed
Trott opened this issue Apr 19, 2018 · 7 comments
Closed

v10.0.0-rc.0 + npm emitting Buffer deprecation warnings #20160

Trott opened this issue Apr 19, 2018 · 7 comments
Labels
buffer Issues and PRs related to the buffer subsystem. confirmed-bug Issues with confirmed bugs. npm Issues and PRs related to the npm client dependency or the npm registry.
Milestone

Comments

@Trott
Copy link
Member

Trott commented Apr 19, 2018

  • Version: v10.0.0-rc.0
  • Platform: macOS
  • Subsystem: buffer
$ uname -a
REDACTED-HOSTNAME 16.7.0 Darwin Kernel Version 16.7.0: Tue Jan 30 11:27:06 PST 2018; root:xnu-3789.73.11~1/RELEASE_X86_64 x86_64
$ NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc nvm install 10
v10.0.0-rc.0 is already installed.
Now using node v10.0.0-rc.0 (npm v5.6.0)
$ node -v
v10.0.0-rc.0
$ npm -v
5.6.0
$ npm install left-pad
(node:39380) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
npm WARN saveError ENOENT: no such file or directory, open '/Users/trott/temp/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/trott/temp/package.json'
npm WARN temp No description
npm WARN temp No repository field.
npm WARN temp No README data
npm WARN temp No license field.
npm WARN You are using a pre-release version of node and things may not work as expected

+ left-pad@1.3.0
added 1 package in 0.653s
$ env | grep NODE
$ env  | grep NVM
NVM_CD_FLAGS=
NVM_DIR=/Users/trott/.nvm
NVM_BIN=/Users/trott/.nvm/versions/node/v10.0.0-rc.0/bin
$ which node
/Users/trott/.nvm/versions/node/v10.0.0-rc.0/bin/node
$ which npm
/Users/trott/.nvm/versions/node/v10.0.0-rc.0/bin/npm
$

Turning on trace warnings so we can see what's causing the warning to be emitted:

$ NODE_OPTIONS='--trace-warnings' npm install left-pad 
(node:39545) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    at showFlaggedDeprecation (buffer.js:159:11)
    at new Buffer (buffer.js:174:3)
    at Object.<anonymous> (/Users/trott/.nvm/versions/node/v10.0.0-rc.0/lib/node_modules/npm/node_modules/tar/lib/parse.js:33:20)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
    at Module.require (internal/modules/cjs/loader.js:626:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/trott/.nvm/versions/node/v10.0.0-rc.0/lib/node_modules/npm/node_modules/tar/lib/list.js:8:16)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
npm WARN saveError ENOENT: no such file or directory, open '/Users/trott/temp/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/trott/temp/package.json'
npm WARN temp No description
npm WARN temp No repository field.
npm WARN temp No README data
npm WARN temp No license field.
npm WARN You are using a pre-release version of node and things may not work as expected

+ left-pad@1.3.0
updated 1 package in 0.64s
$

It seems to be /Users/trott/.nvm/versions/node/v10.0.0-rc.0/lib/node_modules/npm/node_modules/tar/lib/parse.js which should not trigger a warning because it is inside of a node_modules directory. The offending line is:

const gzipHeader = new Buffer([0x1f, 0x8b])
@Trott Trott added this to the 10.0.0 milestone Apr 19, 2018
@Trott Trott added v10.x buffer Issues and PRs related to the buffer subsystem. npm Issues and PRs related to the npm client dependency or the npm registry. labels Apr 19, 2018
@SimenB
Copy link
Member

SimenB commented Apr 19, 2018

FWIW, this happens with yarn (at least installed through brew) as well: yarnpkg/yarn#5704. I installed the RC via nvm, with the help of zsh-nvm

(Also, you can minimize comments in the v10 thread if you want, see https://blog.github.com/2018-04-18-new-tools-for-open-source-maintainers/)

EDIT: Wait, if there is magic around "is inside node_modules" then the yarn case is not relevant as they bundle to a single JS file. Sorry!

@apapirovski
Copy link
Member

Same issue for me on macOS without even using nvm. Just happens when I npm install anything, doesn't even have to be global as far as I can tell.

@apapirovski
Copy link
Member

apapirovski commented Apr 20, 2018

@addaleax I think we might need to make this more lenient and just match anything in node_modules, even if it's at the same level as the main file. See the following code:

return !!match && match[0] !== mainPrefix;

The second part of that conditional creates the problems from what I can tell. Which corresponds to the following test case:

test('/a/node_modules/b.js', '/a/node_modules/x.js', true);

@addaleax
Copy link
Member

@apapirovski What are the values for npm in that case? I’d like to understand why it’s failing (and why it’s failing only on macOS), because we did add this behaviour intentionally

@mcollina
Copy link
Member

Confirmed as well on my machine.

@mcollina mcollina added the confirmed-bug Issues with confirmed bugs. label Apr 20, 2018
@apapirovski
Copy link
Member

@addaleax I think it's failing because code is executing with main being within node_modules. I don't think this is necessarily macOS only. E.g. fsevents runs node install within its own directory within node_modules.

But to go back to npm itself, after digging through it the culprit is here:

https://github.com/npm/npm/blob/8452a9d9b231bc6c95745bb49a4b838ce11d3b9c/lib/install/action/extract.js#L22-L34

@apapirovski apapirovski changed the title v10.0.0-rc.0 + npm emitting Buffer deprecation warnings on macOS v10.0.0-rc.0 + npm emitting Buffer deprecation warnings Apr 20, 2018
@apapirovski
Copy link
Member

Edited the title slightly as it's not just macOS, anything that spins up a process with the main file being within node_modules, gets its warnings printed. Lots of install / post-install scripts are in the mix too.

jasnell pushed a commit that referenced this issue Apr 20, 2018
Due to npm using workers on Windows which inititate processes
for code within node_modules, the current way of testing is a
little too strict to catch all occurrences.

PR-URL: #20163
Fixes: #20160
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. confirmed-bug Issues with confirmed bugs. npm Issues and PRs related to the npm client dependency or the npm registry.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants