Skip to content

[Bug]: "Error while getting the latest version of opencommit" when default npm registry is not registry.npmjs.org #571

Description

@brianrobt

Please note that this issue was generated by Cursor when I asked it about the error below. I'm leaving for vacation in a couple hours but will work on fixing it when I get back next week (if you deem it actually is an issue). It looks like it's just a private registry bug, which may not be a concern for you.

Description

When running oco, the CLI prints an error at startup:

└  Error while getting the latest version of opencommit

The tool continues to work normally after this message, but the error is confusing and looks like a failure.

Root cause

Version checking runs npm view opencommit version without specifying a registry:

// src/version.ts
const { stdout } = await execa('npm', ['view', 'opencommit', 'version']);

If the user's global ~/.npmrc sets a non-public default registry (e.g. AWS CodeArtifact, Artifactory, Verdaccio, or a corporate proxy), npm view targets that registry instead of the public npm registry where opencommit is published. That command then fails — commonly with auth errors like E401 Unable to authenticate — and the catch block prints the error via outro().

Steps to reproduce

  1. Install opencommit globally: npm i -g opencommit@3.3.5
  2. Configure a custom default registry in ~/.npmrc, e.g.:
    registry=https://your-private-registry.example.com/npm/
    
  3. Run oco

Expected: No error; optionally a yellow notice if the installed version is outdated.

Actual: Error while getting the latest version of opencommit is printed before the normal flow continues.

Workaround

Query the public registry explicitly:

npm view opencommit version --registry https://registry.npmjs.org

This succeeds even when the default registry is private.

Suggested fix

In getOpenCommitLatestVersion, pass the public npm registry explicitly:

const { stdout } = await execa('npm', [
  'view',
  'opencommit',
  'version',
  '--registry',
  'https://registry.npmjs.org',
]);

Alternatively, fetch the latest version via the npm registry HTTP API (https://registry.npmjs.org/opencommit/latest) to avoid shelling out to npm entirely.

Also consider downgrading the failure from outro() (error-style output) to a silent skip or a non-blocking debug/warn log, since version checking is optional and should not look like a fatal error.

Environment

  • opencommit: 3.3.5
  • OS: macOS
  • Default npm registry: AWS CodeArtifact (private registry in ~/.npmrc)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions