Skip to content

circular file: dependencies cause npm install to hang #1600

@diachedelic

Description

@diachedelic

What / Why

I suspect this is an issue which is causing npm pack to hang, so I created a minimal reproduction and found it also affects npm install.

When

When running npm install on a package structure which uses circular file: dependencies, npm install enters an infinite loop.

// package.json
{
  "name": "program",
  "version": "1.0.0",
  "dependencies": {
    "foo": "../foo"
  }
}

// ../foo/package.json
{
  "name": "foo",
  "version": "1.0.0",
  "dependencies": {
    "bar": "../bar"
  }
}

// ../bar/package.json
{
  "name": "bar",
  "version": "1.0.0",
  "dependencies": {
    "foo": "../foo"
  }
}
$ npm install --loglevel silly
npm info it worked if it ends with ok
npm verb cli [
npm verb cli   '/Users/me/.nvm/versions/node/v14.4.0/bin/node',
npm verb cli   '/Users/me/.nvm/versions/node/v14.4.0/bin/npm',
npm verb cli   'install',
npm verb cli   '--loglevel',
npm verb cli   'silly'
npm verb cli ]
npm info using npm@6.14.7
npm info using node@v14.4.0
npm verb npm-session 94ac1df1bcf60230
npm sill install runPreinstallTopLevelLifecycles
npm sill preinstall program@1.0.0
npm info lifecycle program@1.0.0~preinstall: program@1.0.0
npm sill install loadCurrentTree
npm sill install readLocalPackageData
npm timing stage:loadCurrentTree Completed in 9ms
npm sill install loadIdealTree
npm sill install cloneCurrentTreeToIdealTree
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
npm sill install loadShrinkwrap
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 3ms
npm sill install loadAllDepsIntoIdealTree
npm sill pacote directory manifest for foo@file:../foo fetched in 9ms
npm sill resolveWithNewModule foo@1.0.0 checking installable status
npm sill pacote directory manifest for bar@file:../bar fetched in 1ms
npm sill resolveWithNewModule bar@1.0.0 checking installable status
npm sill pacote directory manifest for foo@file:../foo fetched in 1ms
npm sill resolveWithNewModule foo@1.0.0 checking installable status
npm sill pacote directory manifest for bar@file:../bar fetched in 1ms
npm sill resolveWithNewModule bar@1.0.0 checking installable status
npm sill pacote directory manifest for foo@file:../foo fetched in 1ms
npm sill resolveWithNewModule foo@1.0.0 checking installable status
npm sill pacote directory manifest for bar@file:../bar fetched in 0ms
npm sill resolveWithNewModule bar@1.0.0 checking installable status
...

Where

Local machine

Steps to Reproduce

git clone git@github.com:diachedelic/npm-hang-repro.git && \
  cd npm-hang-repro/program && \
  npm install --loglevel silly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release 6.xwork is associated with a specific npm 6 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions