question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(cli) trouble publishing to private github packages

See original GitHub issue

Affected Packages

changeset:cli

Problem

I am using the changeset/cli (version, publish) in my github actions workflow for a private GH repo in a private GH organization.

I had npx changeset version working for a moment, using unscoped package names, and npx changeset publish was failing. In order to fix publish, I learned that Github Packages needs package names to be “scoped”. I changed all my package*.json files, code imports and dependencies to use @my-org/some-pkg. Now npx changeset version is failing.

I’m seeing these errors (below) in github action after I merge a PR to main. What’s interesting to note is the old package name dslio appears, but it should say @my-org/dslio. Perhaps the problem is the unscoped name comes from a previous commit? The only place in my repo where this name appears unscoped is in packages/dslio/CHANGELOG.md. Could the CHANGELOG file be the culprit?

Run npx changeset version
🦋  error Error: Could not find package information for dslio
🦋  error     at /home/runner/work/ods/ods/node_modules/@changesets/assemble-release-plan/dist/assemble-release-plan.cjs.dev.js:279:15
🦋  error     at Array.forEach (<anonymous>)
🦋  error     at /home/runner/work/ods/ods/node_modules/@changesets/assemble-release-plan/dist/assemble-release-plan.cjs.dev.js:271:44
🦋  error     at Array.forEach (<anonymous>)
🦋  error     at flattenReleases (/home/runner/work/ods/ods/node_modules/@changesets/assemble-release-plan/dist/assemble-release-plan.cjs.dev.js:266:14)
🦋  error     at Object.assembleReleasePlan [as default] (/home/runner/work/ods/ods/node_modules/@changesets/assemble-release-plan/dist/assemble-release-plan.cjs.dev.js:496:18)
🦋  error     at version (/home/runner/work/ods/ods/node_modules/@changesets/cli/dist/cli.cjs.dev.js:599:60)
🦋  error     at async run$2 (/home/runner/work/ods/ods/node_modules/@changesets/cli/dist/cli.cjs.dev.js:1337:[11](https://github.com/wm-msc-malt/ods/runs/6588470015?check_suite_focus=true#step:9:12))
Error: Process completed with exit code 1.

Here is my GH workflow.

name: Release

on:
  # pull_request_target:
  #   types:
  #     - "closed"
  push:
    branches:
      - main

env:
  AWS_REGION: us-west-2
  HUSKY: 0
  NPM_TOKEN: ${{secrets.GITHUB_TOKEN}}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
  release:
    name: Release
    # if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - name: Show GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"

      # https://github.com/marketplace/actions/github-script
      # - name: View context attributes
      #   uses: actions/github-script@v6
      #   with:
      #     script: console.log(context)

      - name: Checkout Repo
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 14.x
          cache: "npm"

      - name: Update NPM
        run: npm install -g npm@8.9

      - name: Install Dependencies
        run: npm ci

      - name: Setup NX
        uses: nrwl/nx-set-shas@v2
        # main-branch-name: 'main'
      - run: |
          echo "BASE: ${{ env.NX_BASE }}"
          echo "HEAD: ${{ env.NX_HEAD }}"
          npx nx affected:apps

      - name: Changeset Version
        # you should not commit any changes between calling version and publish
        # https://github.com/changesets/changesets/tree/main/packages/cli#publish
        run: |
          npx changeset version
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: NX Build Affected Packages
        run: npm run ci-affected-build

      - name: Changeset Publish
        # you should not commit any changes between calling version and publish
        # https://github.com/changesets/changesets/tree/main/packages/cli#publish
        run: |
          npx changeset publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # # example from https://www.christopherbiscardi.com/post/shipping-multipackage-repos-with-github-actions-changesets-and-lerna
      # - name: Publish Affected Packages
      #   run: npm run ci-affected-publish
      #   env:
      #     NPM_TOKEN: ${{secrets.GITHUB_TOKEN}}

      # - name: Create Release Pull Request
      #   uses: changesets/action@v1
      #   env:
      #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # - name: Git Identity
      #   run: |
      #     git config --global user.name 'github-actions[bot]'
      #     git config --global user.email 'github-actions[bot]@users.noreply.github.com'
      #     git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
      #   env:
      #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Proposed solution

No idea.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
cyrfercommented, May 26, 2022

It worked! It’s done. Finally.

Adding the https url (not the git url) to each package was the final piece of the puzzle. https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#publishing-multiple-packages-to-the-same-repository

thanks @pmcelhaney for the support!

0reactions
cyrfercommented, May 26, 2022

I fixed the Github registry problem. Now I’m looking at this:

I wonder if the action assumes I published once before. I’ll try to publish from my local using a PAT.

🦋  error an error occurred while publishing @omitted-org/omitted-okg: E404 Not Found - PUT https://npm.pkg.github.com/@omitted-org%2fomitted-okg - The expected resource was not found. 
🦋  error 
🦋  error  '@omitted-org/omitted-okg@1.0.2' is not in this registry.
🦋  error 
🦋  error Note that you can also install from a
🦋  error tarball, folder, http url, or git url.
🦋  error npm notice Publishing to https://npm.pkg.github.com/
🦋  error npm ERR! code E404
🦋  error npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/@omitted-org%2fomitted-okg - The expected resource was not found.
🦋  error npm ERR! 404 
🦋  error npm ERR! 404  '@omitted-org/omitted-okg@1.0.2' is not in this registry.
🦋  error npm ERR! 404 
🦋  error npm ERR! 404 Note that you can also install from a
🦋  error npm ERR! 404 tarball, folder, http url, or git url.
🦋  error {
🦋  error   "error": {
🦋  error     "code": "E404",
🦋  error     "summary": "Not Found - PUT https://npm.pkg.github.com/@omitted-org%2fomitted-okg - The expected resource was not found.",
🦋  error     "detail": "\n '@omitted-org/omitted-okg@1.0.2' is not in this registry.\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
🦋  error   }
🦋  error }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring a package's access control and visibility
GitHub Packages is not available for private repositories owned by accounts ... access and can be pulled without authentication or signing in via...
Read more >
[BUG] Can't publish using scoped private registry ... - GitHub
Build a package to dist/admin with the name containing a scope "@vendorname/packagename" and the "publishConfig" key containing a "@vendorname:registry" key.
Read more >
Working with the NuGet registry - GitHub Docs
You can configure the dotnet command-line interface (CLI) to publish NuGet packages to GitHub Packages and to use packages stored on GitHub Packages...
Read more >
Publishing a package - GitHub Docs
You can publish packages in a public repository (public packages) to share with all of GitHub, or in a private repository (private packages)...
Read more >
Unable to publish to GitHub Package Registry · Issue #53
I use the workflow you suggest, but the npm publish action on GitHub Package Registry doesn't work. On npmjs it works.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found