Skip to content

bun publish fails with authentication error despite valid .npmrc in GitHub Actions #24124

Closed

Description

@PepijnSenders

What version of Bun is running?

1.3.1 (89fa0f3)

What platform is your computer?

GitHub Actions (ubuntu-latest)

What steps can reproduce the bug?

  1. Set up GitHub Actions workflow with Bun 1.3.1
  2. Create .npmrc file with valid NPM token:
- name: Setup npm authentication
  run: |
    cat > ~/.npmrc << EOF
    //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
    registry=https://registry.npmjs.org/
    always-auth=true
    EOF
  1. Verify authentication works with npm:
npm whoami  # ✅ Returns username successfully
  1. Try to publish with bun:
bun publish --access public  # ❌ Fails with authentication error

What is the expected behavior?

bun publish should read the .npmrc file and authenticate successfully, just like npm publish does.

What do you see instead?

error: missing authentication (run `bunx npm login`)

Additional information

What we tried:

  1. ✅ .npmrc in ~/.npmrc - Failed
  2. ✅ .npmrc in project root - Failed
  3. ✅ .npmrc in working directory (packages/core/.npmrc) - Failed
  4. ✅ NPM_CONFIG_TOKEN environment variable - Failed
  5. ✅ npm_config_//registry.npmjs.org/:_authToken environment variable - Failed

Evidence that authentication is valid:

Running npm whoami before bun publish succeeds and returns the correct username, proving:

  • The .npmrc file exists and is properly formatted
  • The NPM_TOKEN is valid
  • npm can authenticate successfully

But bun publish immediately after still fails with "missing authentication".

Logs from GitHub Actions:

release  Publish to npm  npm whoami
release  Publish to npm  pep         <-- ✅ npm authentication works!
release  Publish to npm  bun publish v1.3.1 (89fa0f34)
release  Publish to npm  $ bun run build
release  Publish to npm  ...
release  Publish to npm  error: missing authentication (run `bunx npm login`)  <-- ❌ bun fails

Documentation discrepancy:

The Bun docs state:

"bun publish respects the NPM_CONFIG_TOKEN environment variable"

However, this doesn't appear to work in practice with Bun 1.3.1.

Workaround:

We had to revert to using npm publish instead of bun publish:

- name: Publish to npm
  working-directory: ./packages/core
  run: npm publish --access public

This works perfectly with the same .npmrc configuration.

Repository with reproduction:

You can see our full workflow and all attempts at: PepijnSenders/markdown-di#14

Specifically see run logs: https://github.com/PepijnSenders/markdown-di/actions/runs/18837828691

Related issues:

This appears to be an ongoing issue with bun publish authentication in CI environments.

Activity

  1. added
    bug
    bun install
    on Oct 27, 2025
  2. VesperQuartz commented on Dec 10, 2025

    @VesperQuartz

    I am having same error too

  3. stonega commented on Dec 11, 2025

    @stonega

    Same issue.

  4. raphaelbahat commented on Dec 14, 2025

    @raphaelbahat

    Any updates?

  5. pricci1 commented on Dec 25, 2025

    @pricci1

    I have a similar problem, but I'm trying to use NPM's Trusted Publishing, which I believe does not require a token (but I might be confused).

    edit:

    Can confirm that using npm publish works with my setup.

    pricci1/skillify@868404c...121a144

  6. added a commit that references this issue on Dec 25, 2025
  7. evmd commented on Jan 6, 2026

    @evmd

    Had the same issue when trying to publish in CI.
    Something isn't right, after login to npm and having a .npmrc in $HOME, calling bun publish will fail saying it's not authenticated, but doing the following :
    export XDG_CONFIG_HOME="$HOME"
    before running publish solve the issue.

    This really makes no sense.

  8. Ant-Throw-Pology commented on Feb 1, 2026

    @Ant-Throw-Pology

    Had the same issue when trying to publish in CI. Something isn't right, after login to npm and having a .npmrc in $HOME, calling bun publish will fail saying it's not authenticated, but doing the following : export XDG_CONFIG_HOME="$HOME" before running publish solve the issue.

    Same issue here, just not in Actions. Looks to me like Bun is looking in the wrong spot for .npmrc. I don't want to move my $XDG_CONFIG_HOME. Instead, I tried cp ~/.npmrc $XDG_CONFIG_HOME and that also worked.

    bun publish # Failed with auth error, suggesting to run:
    
    bunx npm login
    
    bun publish # Failed, same error
    
    cp ~/.npmrc $XDG_CONFIG_HOME
    
    bun publish # Works!

    I think Bun needs to also look in $HOME for an .npmrc instead of just $XDG_CONFIG_HOME.

  9. evmd commented on Feb 1, 2026

    @evmd

    Had the same issue when trying to publish in CI. Something isn't right, after login to npm and having a .npmrc in $HOME, calling bun publish will fail saying it's not authenticated, but doing the following : export XDG_CONFIG_HOME="$HOME" before running publish solve the issue.

    Same issue here, just not in Actions. Looks to me like Bun is looking in the wrong spot for .npmrc. I don't want to move my $XDG_CONFIG_HOME. Instead, I tried cp ~/.npmrc $XDG_CONFIG_HOME and that also worked.

    bun publish # Failed with auth error, suggesting to run:

    bunx npm login

    bun publish # Failed, same error

    cp ~/.npmrc $XDG_CONFIG_HOME

    bun publish # Works!

    I think Bun needs to also look in $HOME for an .npmrc instead of just $XDG_CONFIG_HOME.

    Just made a PR #26040 to address this fix, now just waiting for @Jarred-Sumner to take care of this annoying bug.

  10. added a commit that references this issue on Feb 17, 2026
  11. Teyik0 commented on Mar 9, 2026

    @Teyik0

    any news ?

  12. 3 remaining items

  13. Jarred-Sumner commented on Jul 28, 2026

    @Jarred-Sumner
    Collaborator

    @robobun adopt

  14. robobun commented on Jul 29, 2026

    @robobun
    Collaborator

    ✅ Reproduced: with XDG_CONFIG_HOME set (GitHub Actions sets it to ~/.config), bun never falls back to ~/.npmrc.
    Fix in progress → #36289

  15. added a commit that references this issue on Jul 29, 2026
    2e73715
  16. added a commit that references this issue on Aug 13, 2026
    930b7af
  17. added a commit that references this issue on Aug 13, 2026
    f1b3a92
  18. added a commit that references this issue on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbun install

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions