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

[@auto-it/npm] Invalid option --registry passed to lerna version #2129

Closed
AndrewLeedham opened this issue Jan 7, 2022 · 11 comments
Closed
Labels
bug Something isn't working

Comments

@AndrewLeedham
Copy link
Contributor

Describe the bug

When upgrading to [email protected] they seem to be more strict about valid options. lerna version as called in auto therefore fails as --registry is an option of lerna publish but not lerna version.

To Reproduce

Expected behavior

In theory [email protected] should be a clean upgrade, but because Auto is using an invalid option it fails.

Environment information:

"auto" version: v10.32.5
"git"  version: v2.30.1 (Apple Git-130)
"node" version: v14.18.1

Additional context

Error log:

Error: Running command 'npx' with args [lerna, version, major, --registry, https://registry.npmjs.org/, --yes, --no-push, --no-git-tag-version, --no-commit-hooks, --exact, --ignore-scripts] failed

ERR! lerna Unknown argument: registry

Code that adds the --registry flag seems to be here: https://github.com/intuit/auto/blob/main/plugins/npm/src/index.ts#L941

@AndrewLeedham
Copy link
Contributor Author

I found a temporary workaround by specifying the registry as https://registry.npmjs.org in my lerna config. Since there is a check against the default which stops it from being added.

@FlomoN
Copy link

FlomoN commented Sep 6, 2022

This workaround doesnt seem to work anymore, but i don't understand why.
I also tried adding (with and without trailing slash) to my lerna.json.

"command": {
    "publish": {
      "registry": "https://registry.npmjs.org"
    }
  }
}

Also in package.json

"publishConfig": {
    "registry": "https://registry.npmjs.org/"
  },

Still when I run npx auto shipit -d I get

‼  warning   lerna notice cli v5.5.0
lerna info versioning independent
lerna info Assuming all packages changed
lerna success found 2 packages ready to publish

‼  warning   lerna notice cli v5.5.0
lerna info versioning independent
lerna success found 2 packages

Error: Running command 'npx' with args [lerna, version, prepatch, --registry, https://registry.npmjs.org/, --yes, --no-push, --no-git-tag-version, --no-commit-hooks, --exact, --ignore-scripts, --preid, canary.523b477] 
failed

ERR! lerna Unbekanntes Argument: registry

Any idea?

@AndrewLeedham
Copy link
Contributor Author

The defaulting code still seems to be there:

async function getRegistryArgs() {
const registry = await getRegistry();
return registry === DEFAULT_REGISTRY || !registry
? []
: ["--registry", registry];
}

The registry is parsed as so, so either should work:

export const getRegistry = async () => {
const { publishConfig = {}, name } = await loadPackageJson();
const lernaJson = isMonorepo() ? getLernaJson() : undefined;
let registry;
if (publishConfig.registry) {
registry = publishConfig.registry;
} else if (lernaJson?.command?.publish?.registry) {
registry = lernaJson.command.publish.registry;
} else if (name?.startsWith("@")) {
const scope = name.split(`/`)[0];
registry = registryUrl(scope);
} else {
registry = registryUrl();
}

The default registry is "https://registry.npmjs.org"

export const DEFAULT_REGISTRY = "https://registry.npmjs.org";

It seems to still be working for me, so I can only assume is isn't detecting the config for some reason?

@FlomoN
Copy link

FlomoN commented Sep 7, 2022

Maybe its something about the --dry-run flag? When i run it without, it seems to work as expected.

nathanstilwell pushed a commit to cockroachdb/ui that referenced this issue Oct 10, 2022
Installing Auto (https://intuit.github.io/auto/index) for automated
publishing. Since this repo has a number of labels already, I disabled
the default labels and added custom entries to match the labels that
were created.

I created a basic workflow for releasing that doesn't have anything
lerna specific (although `lerna` is used internally with `auto`) but run
the `release` npm script (which is `auto shipit --dry-run -v` for now).

Testing locally I ran into an issue where an lerna error will be thrown.
This issue seems to be known (see
intuit/auto#2129) with a workaround by adding
a "registry" entry to lerna.json (although seems to continue to fail
with --dry-run option).
nathanstilwell pushed a commit to cockroachdb/ui that referenced this issue Oct 17, 2022
* Installing and configuring Auto

Installing Auto (https://intuit.github.io/auto/index) for automated
publishing. Since this repo has a number of labels already, I disabled
the default labels and added custom entries to match the labels that
were created.

I created a basic workflow for releasing that doesn't have anything
lerna specific (although `lerna` is used internally with `auto`) but run
the `release` npm script (which is `auto shipit --dry-run -v` for now).

Testing locally I ran into an issue where an lerna error will be thrown.
This issue seems to be known (see
intuit/auto#2129) with a workaround by adding
a "registry" entry to lerna.json (although seems to continue to fail
with --dry-run option).

* Removing dry-run from shipit

After testing the lerna comands locally, I'm removing `--dry-run` to
test publishing canary versions in a pull-request.

* adding `very verbose` logging to diagnose lerna command timeout

* Consistent use of `prepare` and `npm-run-all`

Using `prepare` npm lifecycle script for all packages (as opposed to
prepublishOnly) and consistently using `npm-run-all` for any package
that has multiple scripts to run during `prepare`.

* upgrading gh actions and adding more npm logging

* dropping npm-run-all

* Turning down the logging level
@Webbanditten
Copy link

I'm having the same issue. Running --dry-run results in Unknown argument: registry

@uschtwill
Copy link

Observing the same behaviour.

@ryantang333
Copy link

For anyone still experiencing this issue, downgrading lerna to 3.0.0 is a workaround.

@hipstersmoothie
Copy link
Collaborator

Oooo this seems pretty bad. I hand't noticed this in their changelogs. Would someone experiencing the issue want to make a PR? I'll be fast about merging

@AndrewLeedham
Copy link
Contributor Author

@hipstersmoothie looks like this is no longer relevant, it was added as a global option in [email protected]: lerna/lerna@7.0.1...7.0.2#diff-2032af9ea850f246d979f39fcde239aca6152ebc457758177256ac028123baefR92-R95

Seems redundant to retrospectively fix it, given Auto jumped from 3 - 7.x.

@AndrewLeedham AndrewLeedham closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
@hipstersmoothie
Copy link
Collaborator

Awesome!

@jackw
Copy link
Contributor

jackw commented Jan 18, 2024

I've just hit this issue whilst trying to debug why our repo started creating odd changelogs and unintentionally published a major version. We're running [email protected] and [email protected].

Unfortunately the global --registry argument was later removed in this PR which according to the commit in main was released in v7.2.0.

@hipstersmoothie I've opened a PR here that removes the flag from all version commands that are wrapped in dry-run checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants