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

--reinstall-packages-from fails when local repositories are npm link'd #1519

Open
patrickhulce opened this issue Apr 27, 2017 · 19 comments
Open
Labels
bugs Oh no, something's broken :-( needs followup We need some info or action from whoever filed this issue/PR.

Comments

@patrickhulce
Copy link

  • Operating system and version: macOS Sierra 10.12.4

  • nvm debug output:

nvm --version: v0.33.0
$SHELL: /bin/zsh
$HOME: /Users/phulce
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v7.9.0
which node: $NVM_DIR/versions/node/v7.9.0/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v7.9.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v7.9.0
npm root -g: $NVM_DIR/versions/node/v7.9.0/lib/node_modules
  • nvm ls output:
         v6.9.5
         v7.2.1
->       v7.9.0
default -> v7.2.1
node -> stable (-> v7.9.0) (default)
stable -> 7.9 (-> v7.9.0) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.8.2 (-> N/A)
lts/boron -> v6.10.2 (-> N/A)
  • How did you install nvm? (e.g. install script in readme, homebrew):

homebrew

  • What steps did you perform?

Ran nvm install v7.9.0 --reinstall-packages-from=v7.2.1

  • What happened?

Saw errors in the console and no globally installed packages were reinstalled (yarn for example).

Downloading and installing node v7.9.0...
Downloading https://nodejs.org/dist/v7.9.0/node-v7.9.0-darwin-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v7.9.0 (npm v4.2.0)
VERSION=''
xargs: unterminated quote
Reinstalling global packages from v7.2.1...
Linking global packages from v7.2.1...
nvm_cd:cd:2: no such file or directory: /Users/phulce/Code/npm-linked-package-a\n/Users/phulce/Code/npm-linked-package-b\n/Users/phulce/Code/npm-linked-package-c\n/Users/phulce/Code/npm-linked-package-d\n/Users/phulce/Code/npm-linked-package-e
  • What did you expect to happen?

No errors printed to console and globally installed packages from my previous version are available in the new installation (re-linking local packages that are npm link'd would be a nice bonus but I did not expect it :) )

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

Yes before the nvm.sh eval I add a few local

@ljharb
Copy link
Member

ljharb commented Apr 27, 2017

What's your IFS env var contain?

@patrickhulce
Copy link
Author

Glad I still have that shell open! It's empty...

printf %q "$IFS"
''%

All other open shells have the default

printf %q "$IFS"
\ $'\t'$'\n'%

@ljharb
Copy link
Member

ljharb commented Apr 27, 2017

aha - if, in that same shell, you set it to the default, is the problem fixed?

@patrickhulce
Copy link
Author

nope, I get the same result. The nvm install command seems to be the culprit for setting IFS to empty

> printf %q "$IFS"
\ $'\t'$'\n'%
> nvm install v7.9.0 --reinstall-packages-from=v7.2.1
Downloading and installing node v7.9.0...
Local cache found: $NVM_DIR/.cache/bin/node-v7.9.0-darwin-x64/node-v7.9.0-darwin-x64.tar.xz
Checksums match! Using existing downloaded archive $NVM_DIR/.cache/bin/node-v7.9.0-darwin-x64/node-v7.9.0-darwin-x64.tar.xz
Now using node v7.9.0 (npm v4.2.0)
VERSION=''
xargs: unterminated quote
Reinstalling global packages from v7.2.1...
Linking global packages from v7.2.1...
nvm_cd:cd:2: no such file or directory: ...
> printf %q "$IFS"
''%

@ljharb
Copy link
Member

ljharb commented Apr 27, 2017

Seems like #1518 is related, but that's not the entirety of the problem.

Can you provide the output of nvm use 7.2.1 ; npm ls -g ; nvm_npm_global_modules?

@ljharb
Copy link
Member

ljharb commented Apr 27, 2017

(There's a totally separate issue where IFS isn't reset inside nvm reinstall-packages if npm link fails)

@patrickhulce
Copy link
Author

Ah progress! Looks like I had one npm link directory leftover that I had since deleted which showed up in npm ls -g. After removing that link, it successfully installed my regular packages 👍 I still got the error on trying to do the linking on the new version though

Linking global packages from v7.2.1...
nvm_cd:cd:2: no such file or directory: /path/to/link-a\n/path/to/link-b\n/path/to/link-c...

@ljharb
Copy link
Member

ljharb commented Apr 28, 2017

@patrickhulce i'd still have needed to see the original output of those commands to fix the problem :-/ can you provide the output requested in #1519 (comment) ?

@ljharb ljharb added bugs Oh no, something's broken :-( needs followup We need some info or action from whoever filed this issue/PR. labels Apr 28, 2017
@patrickhulce
Copy link
Author

nvm use 7.2.1

Now using node v7.2.1 (npm v3.10.10)

npm ls -g
log of output plus the stderr below

npm ERR! extraneous: mocha@3.2.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/generator-npm-package/node_modules/mocha
npm ERR! extraneous: @types/node@6.0.46 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/@types/node
npm ERR! extraneous: coveralls@2.11.14 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/coveralls
npm ERR! extraneous: eslint@3.12.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/eslint
npm ERR! extraneous: eslint-config-google@0.7.1 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/eslint-config-google
npm ERR! extraneous: google-closure-compiler@20161201.0.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/google-closure-compiler
npm ERR! extraneous: gulp@3.9.1 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/gulp
npm ERR! extraneous: gulp-concat@2.6.1 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/gulp-concat
npm ERR! extraneous: gulp-declare@0.3.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/gulp-declare
npm ERR! extraneous: gulp-define-module@0.1.5 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/gulp-define-module
npm ERR! extraneous: gulp-handlebars@4.0.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/gulp-handlebars
npm ERR! extraneous: gulp-replace@0.5.4 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/gulp-replace
npm ERR! extraneous: istanbul@0.4.5 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/istanbul
npm ERR! extraneous: jsdom@9.12.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/jsdom
npm ERR! extraneous: mocha@3.2.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/mocha
npm ERR! extraneous: zone.js@0.7.3 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/lighthouse/node_modules/zone.js
npm ERR! extraneous: ava@0.14.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/speedline/node_modules/ava
npm ERR! extraneous: fs-promise@0.5.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/speedline/node_modules/fs-promise
npm ERR! extraneous: jimp@0.2.27 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/speedline/node_modules/jimp
npm ERR! extraneous: node-pre-gyp@0.6.34 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/speedline/node_modules/node-pre-gyp
npm ERR! extraneous: sobel@0.0.7 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/speedline/node_modules/sobel
npm ERR! extraneous: xo@0.14.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/speedline/node_modules/xo
npm ERR! extraneous: ava@0.18.2 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/ava
npm ERR! extraneous: babel-eslint@7.1.1 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/babel-eslint
npm ERR! extraneous: coveralls@2.11.16 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/coveralls
npm ERR! extraneous: eslint-config-xo-react@0.10.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/eslint-config-xo-react
npm ERR! extraneous: eslint-import-resolver-webpack@0.8.1 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/eslint-import-resolver-webpack
npm ERR! extraneous: eslint-plugin-react@6.10.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/eslint-plugin-react
npm ERR! extraneous: nyc@8.4.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/nyc
npm ERR! extraneous: proxyquire@1.7.11 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/proxyquire
npm ERR! extraneous: temp-write@2.1.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/temp-write
npm ERR! extraneous: xo@0.16.0 /Users/phulce/.nvm/versions/node/v7.2.1/lib/node_modules/xo/node_modules/xo

nvm_npm_global_modules

Seemingly errors ```sh nvm_npm_global_modules No .nvmrc file found

Node Version Manager

Note: refers to any version-like string nvm understands. This includes:

  • full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
  • default (built-in) aliases: node, stable, unstable, iojs, system
  • custom aliases you define with nvm alias foo

Any options that produce colorized output should respect the --no-colors option.

Usage:
nvm --help Show this message
nvm --version Print out the latest released version of nvm
nvm install [-s] Download and install a , [-s] from source. Uses .nvmrc if available
--reinstall-packages-from= When installing, reinstall packages installed in <node|iojs|node version number>
--lts When installing, only select from LTS (long-term support) versions
--lts= When installing, only select from versions for a specific LTS line
nvm uninstall Uninstall a version
nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias lts/*, if available.
nvm uninstall --lts= Uninstall using automatic alias for provided LTS line, if available.
nvm use [--silent] Modify PATH to use . Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm exec [--silent] [] Run on . Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm run [--silent] [] Run node on with as arguments. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm current Display currently activated version
nvm ls List installed versions
nvm ls List versions matching a given
nvm ls-remote List remote versions available for install
--lts When listing, only show LTS (long-term support) versions
nvm ls-remote List remote versions available for install, matching a given
--lts When listing, only show LTS (long-term support) versions
--lts= When listing, only show versions for a specific LTS line
nvm version Resolve the given description to a single local version
nvm version-remote Resolve the given description to a single remote version
--lts When listing, only select from LTS (long-term support) versions
--lts= When listing, only select from versions for a specific LTS line
nvm deactivate Undo effects of nvm on current shell
nvm alias [] Show all aliases beginning with
nvm alias Set an alias named pointing to
nvm unalias Deletes the alias named
nvm reinstall-packages Reinstall global npm packages contained in to current version
nvm unload Unload nvm from shell
nvm which [] Display path to installed node version. Uses .nvmrc if available
nvm cache dir Display path to the cache directory for nvm
nvm cache clear Empty cache directory for nvm

Example:
nvm install v0.10.32 Install a specific version number
nvm use 0.10 Use the latest available 0.10.x release
nvm run 0.10.32 app.js Run app.js using node v0.10.32
nvm exec 0.10.32 node app.js Run node app.js with the PATH pointing to node v0.10.32
nvm alias default 0.10.32 Set default node version on a shell

Note:
to remove, delete, or uninstall nvm - just remove the $NVM_DIR folder (usually ~/.nvm)

////

</details>

@ljharb
Copy link
Member

ljharb commented Apr 28, 2017

whoops, my bad. @patrickhulce can you run nvm_npm_global_modules $(nvm current) instead?

@patrickhulce
Copy link
Author

that makes more sense :) looks like those are expecting to be space delimited?

bower@1.8.0 diff-so-fancy@0.11.4 google-closure-compiler-js@20170124.0.0 gulp@3.9.1 http-server@0.9.0 imagemin-cli@3.0.0 mocha@3.2.0 prettier@0.22.0 semantic-release-cli@3.0.3 typescript@2.2.1 webpack@1.14.0 webpack-dev-server@1.16.2 yarn@0.20.3 yo@1.8.5 //// /Users/phulce/Code/OpenSource/lint
/Users/phulce/Code/OpenSource/generator-npm-package
/Users/phulce/Code/Chrome/lighthouse
/Users/phulce/Code/OpenSource/speedline
/Users/phulce/Code/OpenSource/xo

@ljharb
Copy link
Member

ljharb commented Apr 28, 2017

actually that output looks correct (the first half is space-delimited, the last half is newline-delimited)

However, I'm wondering if your IFS setting caused the same issue. What happens if you set IFS to the default ($' \t\n'), or unset it entirely?

@patrickhulce
Copy link
Author

Oh I should've clarified above that 2nd run was with IFS explicitly set back to default, I get identical results when unsetting it entirely

@ljharb
Copy link
Member

ljharb commented Apr 28, 2017

I see that you're on zsh; any chance it's oh-my-zsh, or that you have some nondefault options set?

zsh options often break nvm; if that's the case, what's the output of your setopt?

@patrickhulce
Copy link
Author

Ah ok, yes it's oh-my-zsh.

alwaystoend
autocd
autopushd
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
nonomatch
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle

@ljharb
Copy link
Member

ljharb commented Apr 29, 2017

The options that I don't have set on my stock zsh are:

alwaystoend
autocd
autopushd
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactivecomments
login
longlistjobs
promptsubst
pushdignoredups
pushdminus
sharehistory

The best way to figure this out quickly is for you to do a binary search - in other words, unset half of them, try again, then go back to only having half the failing half set, try again, etc, until we've narrowed it down.

Once that's done, I can fix it by wrapping the command in "unset the opt, do the command, restore the opt".

@patrickhulce
Copy link
Author

Alright I'll give that a shot later this week, it became considerably less urgent once the regular globals were brought over :) thanks for the help!

@ljharb
Copy link
Member

ljharb commented May 1, 2017

Thanks, no hurry, but it's exceedingly hard to reproduce issues like this, so it'd be very very helpful for you to help me narrow it down to a single option :-)

@kerryChen95
Copy link

I also got nvm xargs: unterminated quote when run nvm reinstall-packages v8.1.2.

Then I run npm list -g and got an error saying something wrong about $NVM_DIR/versions/node/v8.1.2/lib/node_modules/@mi/.DS_Store, the error log indeed contains non-closing quotes, unfortunately I cleared that log.

But after rm -fr $NVM_DIR/versions/node/v8.1.2/lib/node_modules/@mi/.DS_Store, I fixed this problem, nvm reinstall-packages v8.1.2 run as expected.

So maybe you can run npm list -g to see is there any error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( needs followup We need some info or action from whoever filed this issue/PR.
Projects
None yet
Development

No branches or pull requests

3 participants