Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview build setup sometimes results in installation failures #1075

Closed
Gudahtt opened this issue Jan 24, 2023 · 8 comments · Fixed by #1622
Closed

Preview build setup sometimes results in installation failures #1075

Gudahtt opened this issue Jan 24, 2023 · 8 comments · Fixed by #1622
Assignees
Labels

Comments

@Gudahtt
Copy link
Member

Gudahtt commented Jan 24, 2023

It seems that the GitHub registry we have setup for the preview builds isn't mirroring packages from npm.

As a consequence, you may see installation failures non-preview @metamask packages when using an .npmrc file setup to point at the GitHub registry. I've found that I can get past the error by ensuring the non-preview packages are installed locally before putting the .npmrc file in-place. This is a viable workaround but it requires frequently adding and removing this file, which is rather inconvenient.

@Gudahtt Gudahtt added the enhancement New feature or request label Jan 24, 2023
@Gudahtt
Copy link
Member Author

Gudahtt commented Jan 24, 2023

I was unable to find any way to configure Yarn/npm or GitHub to support looking at this custom registry first, then falling back to npm.

We may want to investigate alternatives to GitHub Packages. Or perhaps we could write a script to sync all of our npm packages to the GitHub registry.

Mrtenz added a commit to MetaMask/snaps that referenced this issue Apr 5, 2023
Warn the potential problem when installing non-preview `@metamask/`-scoped packages while using preview builds. Users can solve this by removing the `.npmrc` / `.yarnrc.yml` changes to install the missing packages and restoring the preview build credentials afterward. For more detail, check [issue #1075](MetaMask/core#1075).
Mrtenz added a commit to MetaMask/snaps that referenced this issue Apr 11, 2023
Warn the potential problem when installing non-preview `@metamask/`-scoped packages while using preview builds. Users can solve this by removing the `.npmrc` / `.yarnrc.yml` changes to install the missing packages and restoring the preview build credentials afterward. For more detail, check [issue #1075](MetaMask/core#1075).
Mrtenz added a commit to MetaMask/snaps that referenced this issue Apr 11, 2023
Warn the potential problem when installing non-preview `@metamask/`-scoped packages while using preview builds. Users can solve this by removing the `.npmrc` / `.yarnrc.yml` changes to install the missing packages and restoring the preview build credentials afterward. For more detail, check [issue #1075](MetaMask/core#1075).
hmalik88 pushed a commit to MetaMask/snaps that referenced this issue Jun 15, 2023
…review builds (#1332)

* Add warning for non-preview package installation in README

Warn the potential problem when installing non-preview `@metamask/`-scoped packages while using preview builds. Users can solve this by removing the `.npmrc` / `.yarnrc.yml` changes to install the missing packages and restoring the preview build credentials afterward. For more detail, check [issue #1075](MetaMask/core#1075).

* Fix typo in README.md

Changed "you can workaround the problem" to "you can work around the problem".

---------

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
GuillaumeRx pushed a commit to MetaMask/snaps that referenced this issue Jun 22, 2023
…review builds (#1332)

* Add warning for non-preview package installation in README

Warn the potential problem when installing non-preview `@metamask/`-scoped packages while using preview builds. Users can solve this by removing the `.npmrc` / `.yarnrc.yml` changes to install the missing packages and restoring the preview build credentials afterward. For more detail, check [issue #1075](MetaMask/core#1075).

* Fix typo in README.md

Changed "you can workaround the problem" to "you can work around the problem".

---------

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
@BelfordZ
Copy link
Contributor

can we publish previews to npm instead?

solves:

  1. does not require a token to view previews
  2. doesnt require any yarnrc configuration to use them

tradeoffs:

  1. gh action will require an npm token that can publish releases. We can resolve security risk by pushing them to a different org (@metamask-previews for example)
  2. ??

@mcmire
Copy link
Contributor

mcmire commented Jul 28, 2023

@BelfordZ This does seem like the easiest plan. @Gudahtt What say you to using a different NPM scope?

@Gudahtt
Copy link
Member Author

Gudahtt commented Aug 1, 2023

As long as we can resolve to the new package name, that works. I'm not sure if that's possible with Yarn v3 for transitive dependencies.

e.g. if we have a new @metamask/eth-sig-util@5.0.1 release, how do we point all copies of @metamask/eth-sig-util@5.0.0 in our dependency tree at @metamask-previews/eth-sig-util@something?

Maybe Yarn resolutions can do this? Not sure.

@mcmire
Copy link
Contributor

mcmire commented Aug 1, 2023

I think that Yarn resolutions can accomplish this as well, but we would definitely need to test this out somehow. I can try experimenting with this.

@xinnanyemm
Copy link

Hey team! Please add your planning poker estimate with Zenhub @cryptodev-2s @Gudahtt @mcmire @mikesposito

@mcmire
Copy link
Contributor

mcmire commented Aug 4, 2023

I tried to test the above idea by using Verdaccio to publish a @metamask-previews package locally. However, I could not get Verdaccio to work with Yarn v3. After pointing Yarn to using http://localhost:4873 instead of the Yarn registry, I kept getting an ECONNREFUSED error. I'll have to try something else, perhaps using the GitHub registry instead.

@mcmire
Copy link
Contributor

mcmire commented Aug 5, 2023

I've tested this using the GitHub registry instead and confirmed that the resolutions field works to get Yarn to "see" one package under another name in the dependency tree.

I first added the following to .yarnrc.yml in this repo:

npmRegistries:
  "https://npm.pkg.github.com":
    npmAlwaysAuth: true
    npmAuthToken: "${GITHUB_NPM_TOKEN-}"

npmScopes:
  mcmire:
    npmRegistryServer: "https://npm.pkg.github.com"

I then opened the package.json for controller-utils and:

  • changed its name from @metamask/controller-utils to @mcmire/controller-utils in package.json
  • changed the version by appending -preview.aaa to the end
  • updated publishConfig.registry to "https://npm.pkg.github.com"

I then found every instance of @metamask/controller-utils in package.json across the whole monorepo and replaced it with @mcmire/controller-utils, then ran:

yarn install

I then ran:

GITHUB_NPM_TOKEN="<token>" yarn workspace @mcmire/controller-utils npm publish --tag preview

Over in the extension I then added the same section to .yarnrc.yml as above. When I added this to the resolutions field:

"@metamask/controller-utils": "npm:@mcmire/controller-utils@preview"

and ran:

GITHUB_NPM_TOKEN="<token>" yarn install

and then

yarn why @metamask/controller-utils

I saw that every instance of controller-utils in the dependency tree was replaced:

├─ @metamask/address-book-controller@npm:3.1.0
│  └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest)
│
├─ @metamask/assets-controllers@npm:9.2.0
│  └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest)
│
├─ @metamask/assets-controllers@npm:9.2.0 [15918]
│  └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest)
│
├─ @metamask/base-controller@npm:2.0.0
│  └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants