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
- Install opencommit globally:
npm i -g opencommit@3.3.5
- Configure a custom default registry in
~/.npmrc, e.g.:
registry=https://your-private-registry.example.com/npm/
- 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
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: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 versionwithout specifying a registry:If the user's global
~/.npmrcsets a non-public default registry (e.g. AWS CodeArtifact, Artifactory, Verdaccio, or a corporate proxy),npm viewtargets that registry instead of the public npm registry whereopencommitis published. That command then fails — commonly with auth errors likeE401 Unable to authenticate— and the catch block prints the error viaoutro().Steps to reproduce
npm i -g opencommit@3.3.5~/.npmrc, e.g.:ocoExpected: No error; optionally a yellow notice if the installed version is outdated.
Actual:
Error while getting the latest version of opencommitis printed before the normal flow continues.Workaround
Query the public registry explicitly:
This succeeds even when the default registry is private.
Suggested fix
In
getOpenCommitLatestVersion, pass the public npm registry explicitly:Alternatively, fetch the latest version via the npm registry HTTP API (
https://registry.npmjs.org/opencommit/latest) to avoid shelling out tonpmentirely.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
~/.npmrc)Related