-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Bug?]: yarn patch generated unparsable patch: URL #4711
Comments
hmm... I wonder if this is the same as the problem I just came here to report |
I don't get an error though, mine just silently doesn't apply |
linked my bug, seems very related to both that you mentioned, but mine seems to be both of the problems at once... |
OMG, I want to kiss you right now. I struggled with this for MONTHS, manually applying the patches. |
Hi! 👋 This issue looks stale, and doesn't feature the Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃 If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the |
I couldn't figure out how exactly to reproduce this issue using Sherlock. Last time I tried to use it, the page failed to load the editor properly, so I gave up and assumed the tool was broken. I explained the steps to reproduce in the description. I'll need a maintainer to help out. |
This is my completely blind attempt at repro, as playground is not working, and local Sherlock does not expose (undocumented) methods like const installPromise = packageJsonAndInstall({
dependencies: {
[`@codertocat/hello-world-npm`]: `latest`,
},
});
await expect(installPromise).resolves.toBeTruthy();
// Use node_modules resolver
// await yarn(`config`, `set nodeLinker node-modules`);
// Set npmRegistryServer
await yarn(`config`, `set npmRegistryServer "https://npm.pkg.github.com"`);
// Extract the package for patching
const patchOutput = await yarn(`patch`, `@codertocat/hello-world-npm`);
const patchOutputLines = patchOutput.split("\n");
// Look for "You can now edit the following folder: …"
const regex1 = /You can now edit the following folder: (.*)/;
const line1 = patchOutputLines.find((line) => line.match(regex1));
const folder = line1.match(regex1)[1];
// Make the edit in extracted package README.md file
const filePath = path.join(path.resolve(folder), `index.js`);
const file = await fs.readFile(filePath, `utf8`);
await fs.writeFile(
filePath,
file.replace("'Hello world!'", "'Hello world from patch!'")
);
// Look for "Once you are done run … and Yarn will store a patchfile based on your changes."
const regex2 =
/Once you are done run (.*) and Yarn will store a patchfile based on your changes./;
const line2 = patchOutputLines.find((line) => line.match(regex2));
const command = line2.match(regex2)[1];
const [yarnText, commandText, ...args] = command.split(" ");
// Run the command
await yarn(commandText, ...args);
// Install repo again to apply patches
const install2Promise = await yarn(`install`);
/**
* BUG #1:
* Error: @codertocat/hello-world-npm@npm:1.0.2::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40Codertocat%2Fhello-world-npm%2F1.0.2%2F9384a68bd287b859f028683bcaacedd27803f1dd isn't supported by any available resolver
**/
expect(install2Promise).resolves.toBeTruthy();
// See if the patch was applied
const installedModule = require("@codertocat/hello-world-npm");
const output = installedModule.helloWorld();
/**
* BUG #2: Patch not applied?
*/
expect(output).toEqual("Hello world from patch!"); |
Mind trying the 4.0.0-rc ( |
@arcanis I did the tests on 2 dimensions:
Here are the commands I ran: # 4.0.0 ONLY:
yarn set version canary
yarn config set nodeLinker node-modules
yarn config set npmRegistryServer "https://npm.pkg.github.com"
# CARET ONLY:
yarn add @codertocat/hello-world-npm@^1.0.0
# EXACT ONLY:
yarn add @codertocat/[email protected]
yarn patch @codertocat/hello-world-npm
# (editing the file now by changing "Hello world!" to "Hello world from patch!" & saving it)
yarn patch-commit -s # (dynamically created folder path here)
yarn All 4 resulted in the exact same crash.
Here are all 4 minirepos I created to reproduce this issue: In all 4 cases, removing I have a suspicion that releasing 1.0.3 version of test package would break patch on 3.2.3 as resolution created by patch-commit would no longer be applicable. But that's another story. |
I found this article quite helpful to understand the bug and how to work around it: https://charles-stover.medium.com/patching-packages-in-yarn-berry-72e4ded29a56 |
I'm still getting this in v4.1.0. I wish Yarn would implement some sort of e2e test around the |
For documentation's sake, I fixed this by changing |
Here's a simple reproduction I came up with: const { writeFile } = require(`fs/promises`);
await writeFile('.yarnrc.yml', `
npmScopes:
types:
npmRegistryServer: https://registry.npmjs.com
`);
await packageJsonAndInstall({
devDependencies: {
"lodash": "^4.17.21",
"@types/lodash": "^4.14.202"
}
});
const { path } = JSON.parse(await yarn('patch', '@types/lodash', '--json'));
await yarn('patch-commit', '-s', path);
await expect(yarn('install')).resolves.toBeTruthy(); @lachlanhunt Could you add this into your issue description? |
just being a fresh user of yarn I find 'yarn patch' not to be working (yarn 4.1.1 with custom npmRegistry, scoped packages and workspaces). Will now try to dig into it and find a workaround |
it seems to work when I do:
seems like it's doing as intended, while not being the most easy user experience though. ;) I found some hints in #3012 regardingt the usage of __archiveUrl and non-conformant registry-servers (artifactory in my case), maybe that helps in getting this issue ironed out at some later point |
i am also facing same from last one week. |
i was getting issue with installing yarn with homebrew. it worked after updating my yarn & node version to : to install yarn please follow this link : https://stackoverflow.com/a/78307944/2382964 |
Self-service
Describe the bug
My company uses an internal package registry where all npm packages are fetched from. This is configured in ~/.yarnrc.yaml (company name replaced with
example
)The result of this is that the resolution for the package in yarn.lock looks like this:
When I tried to patch this packing using:
(Then I fixed the version range in that resolution as described in #4231 (comment) )
Finally, running
yarn
to apply the patch gives this error:I was able to work around this issue by modifying the
patch:
URL like this:It appears the presence of
::__archiveUrl=https...
breaks the parsing of the patch URL in yarn.To reproduce
(as explained above)
edit: see reproduction in comment below #4711 (comment)
Environment
System: OS: macOS 12.5 CPU: (10) arm64 Apple M1 Pro Binaries: Node: 16.16.0 - /private/var/folders/78/vv5cyf6570xcqbsy0r2nfyfw0000gn/T/xfs-99d9804c/node Yarn: 3.2.2 - /private/var/folders/78/vv5cyf6570xcqbsy0r2nfyfw0000gn/T/xfs-99d9804c/yarn npm: 8.11.0 - ~/Library/Caches/fnm_multishells/21303_1659328957074/bin/npm
Additional context
No response
The text was updated successfully, but these errors were encountered: