Repository navigation
Closed
Description
Expected Behavior
If publish is going to fail since no token set, then abort early to prevent the repository being left in a half-published state.
Current Behavior
If no token set, publish proceeds regardless, resulting in:
? Are you sure you want to publish the above changes? Yes
lerna info publish Publishing packages to npm...
lerna ERR! publish Retrying failed publish: @neutrinojs/chunk
lerna ERR! publish Retrying failed publish: @neutrinojs/babel-minify
lerna ERR! publish Retrying failed publish: @neutrinojs/clean
lerna ERR! publish Retrying failed publish: @neutrinojs/banner
lerna ERR! publish Retrying failed publish: @neutrinojs/banner
lerna ERR! publish Retrying failed publish: @neutrinojs/chunk
lerna ERR! publish Retrying failed publish: @neutrinojs/clean
lerna ERR! publish Retrying failed publish: @neutrinojs/babel-minify
lerna ERR! publish Retrying failed publish: @neutrinojs/banner
lerna ERR! publish Retrying failed publish: @neutrinojs/chunk
lerna ERR! publish Retrying failed publish: @neutrinojs/babel-minify
lerna ERR! publish Retrying failed publish: @neutrinojs/clean
lerna ERR! publish Retrying failed publish: @neutrinojs/banner
lerna ERR! publish Retrying failed publish: @neutrinojs/chunk
lerna ERR! publish Retrying failed publish: @neutrinojs/clean
lerna ERR! publish Retrying failed publish: @neutrinojs/babel-minify
lerna ERR! publish Ran out of retries while publishing @neutrinojs/banner Error: Command failed: yarn publish --tag latest --new-version 8.2.0
lerna ERR! publish error An unexpected error occurred: "No token found and can't prompt for login when running with --non-interactive.".
lerna ERR! publish [1/4] Bumping version...
lerna ERR! publish info Current version: 8.2.0
lerna ERR! publish [2/4] Logging in...
lerna ERR! publish info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\Ed\\src\
lerna ERR! publish eutrino-dev\\packages\\banner\\yarn-error.log".
lerna ERR! publish info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
lerna ERR! publish
lerna ERR! publish at Promise.all.then.arr (C:\Users\Ed\src\neutrino-dev\node_modules\lerna\node_modules\execa\index.js:236:11)
lerna ERR! publish at <anonymous>
lerna ERR! publish at process._tickCallback (internal/process/next_tick.js:118:7)
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: yarn publish --tag latest --new-version 8.2.0
...
Possible Solution
If npm publishing is enabled (ie the user hasn't passed --skip-npm to lerna publish), then check to see whether a token is set, and if not, abort the publish before doing anything.
Steps to Reproduce (for bugs)
- Clear authentication tokens set in
.npmrc/.yarnrc - Run
lerna publishin a repo that uses lerna
lerna.json
{
"lerna": "2.4.0",
"packages": [
"packages/*"
],
"version": "8.2.0",
"gitRemote": "upstream",
"npmClient": "yarn",
"registry": "https://registry.npmjs.org/",
"useWorkspaces": true
}Context
I thought lerna publish would prompt me for a token, avoiding the need to save it to disk. However it doesn't, and left my local state half-published, meaning I'm not sure how to retry the publish without manually unpicking the changes.
Your Environment
| Executable | Version |
|---|---|
lerna --version |
2.9.0 |
npm --version |
5.6.0 |
yarn --version |
1.5.1 |
node --version |
9.7.1 |
| OS | Version |
|---|---|
| NAME | VERSION |
| Windows 10 | 1709 |
Reacted by Bartek Igielski, Taupemist, Andrii, Brian Muenzenmeyer, futpib, noyobo, Alexander and Bastian Schade
Metadata
Metadata
Assignees
Labels
No labels
Activity
evocateur commentedon Mar 24, 2018
It's not lerna's responsibility to set a token, or even be aware of what that token is/where it is located. I agree we should probably run
npm whoami(yarn equivalent ???) at the beginning of publish just so the inevitable error can be helpful/informative instead of damaging.edmorley commentedon Apr 3, 2018
Hi! Yeah I agree it's not lerna's responsibility to handle setting the token; this issue was just about failing early to limit the damage it causes. I can't seem to find a yarn equivalent to
npm whoami- perhaps lerna can just usenpm whoamiregardless of the value ofnpmClient?evocateur commentedon Apr 3, 2018
I have a hunch yarn has different opinions about how to resolve registry authentication. No actual proof, just bitter experience of several yarn-related lerna bugs due to inconsistent implementation of registry patterns.
b4lk0n commentedon May 22, 2018
Faced a similar issue. Publishing anonymously to private registry (proget). When
yarn publishworks as expected, butlerna publishfails with "No token found and can't prompt for login when running with --non-interactive." errorlock commentedon Dec 27, 2018
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.