Skip to content

[BUG] Plain VLT_TOKEN is ignored unless VLT_REGISTRY is set (does not apply to the default registry alias) #1845

Closed

Description

@ruy-bot

🐛 Bug Report

cli/auth.mdx says:

A token for the default registry can be provided in the VLT_TOKEN environment variable.

and the OIDC section says vlt "falls back to VLT_TOKEN". In practice VLT_TOKEN is only honored when VLT_REGISTRY is set (or a registry scalar is configured, which the config layer exports as VLT_REGISTRY). Users who followed the guided vlt setup path only get registries.npm / registries.main aliases written to their config, so for them VLT_TOKEN is silently ignored.

✅ Expected Behavior

VLT_TOKEN=<tok> vlt install authenticates requests to the default registry, i.e. the registry selected by default-registry-alias (which is what vlt setup configures), regardless of whether VLT_REGISTRY is set.

❌ Actual Behavior

With vlt.json containing only registries.npm (as written by vlt setup), VLT_TOKEN=x vlt install sends no Authorization header (reproduced against a local logging registry: auth=null). Setting VLT_REGISTRY in addition makes it work.

Root cause

getToken() in src/registry-client/src/auth.ts:

  const envReg = process.env.VLT_REGISTRY
  if (envReg && key === normalizeRegistryKey(envReg)) {
    const envTok = process.env.VLT_TOKEN
    if (envTok) return `Bearer ${envTok}`
  }

VLT_TOKEN is gated on a VLT_REGISTRY match only; the default-registry-alias / registries config is never considered.

Fix options

  1. Apply VLT_TOKEN to the registry selected by default-registry-alias (and/or to the registry scalar) — preferred, matches the docs.
  2. Or document that VLT_TOKEN requires VLT_REGISTRY (or a registry scalar) to be in effect.

Related: the per-registry VLT_TOKEN_* form is also broken at the request level (see the linked issue), so today the only env-based auth that works is VLT_REGISTRY + VLT_TOKEN, and only for a single registry.

🌍 Environment

  • OS: linux
  • Node: 24.18.1
  • vlt: 1.0.8 (auth.ts unchanged at current main)

🔄 Frequency

Always

Activity

  1. ruy-bot commented on Sep 14, 2026

    @ruy-bot
    ContributorAuthor

    Related: #1844 (VLT_TOKEN_* per-registry form also broken at request level).

  2. added
    bug
    cli
    on Sep 14, 2026
  3. lukekarrys commented on Sep 14, 2026

    @lukekarrys
    Member

    I ran into this previously and found that jackspeak does set VLT_REGISTRY as an environment variable. So even if it's not set explicitly, it will still end up running that branch. I think this is still the case today but I haven't confirmed with any code.

  4. self-assigned this
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcliregistry

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions