-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
I can't create a patch #547
Comments
the same issue |
Tried to debug it, here's what I found
patch-package/src/makePatch.ts Lines 208 to 225 in c7c63bf
Both of them fail, here's the decoded STDs outputs stdout:
stderr:
|
I'll link this issue yarnpkg/berry#5802 But I think that ultimately, the issue is that patch package should copy the "packageManager" field to the temp |
Here's a patch that made it work for me Index: src/makePatch.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/makePatch.ts b/src/makePatch.ts
--- a/src/makePatch.ts (revision c7c63bf80b3c6b8640b933e20229121b4edfc100)
+++ b/src/makePatch.ts (date 1732647948973)
@@ -183,6 +183,7 @@
appPath,
appPackageJson.resolutions || {},
),
+ packageManager: appPackageJson.packageManager
}),
)
@@ -193,7 +194,7 @@
// copy .npmrc/.yarnrc in case packages are hosted in private registry
// copy .yarn directory as well to ensure installations work in yarn 2
// tslint:disable-next-line:align
- ;[".npmrc", ".yarnrc", ".yarn"].forEach((rcFile) => {
+ ;[".npmrc", ".yarnrc", ".yarnrc.yml", ".yarn"].forEach((rcFile) => {
const rcPath = join(appPath, rcFile)
if (existsSync(rcPath)) {
copySync(rcPath, join(tmpRepo.name, rcFile), { dereference: true })
@@ -208,7 +209,12 @@
try {
// try first without ignoring scripts in case they are required
// this works in 99.99% of cases
- spawnSafeSync(`yarn`, ["install", "--ignore-engines"], {
+ // FIXME: yarn --ignore-engines causes yarn to warn on stderr
+ // spawnSafeSync(`yarn`, ["install", "--ignore-engines"], {
+ // cwd: tmpRepoNpmRoot,
+ // logStdErrOnError: false,
+ // })
+ spawnSafeSync(`yarn`, ["install"], {
cwd: tmpRepoNpmRoot,
logStdErrOnError: false,
}) I'm not 100% sure bout the need for the |
thanks friend, I'll try the solution and write about the result |
It feels illegal to use I modified the patch a bit for diff --git a/node_modules/patch-package/dist/makePatch.js b/node_modules/patch-package/dist/makePatch.js
index d8d0925..9b25269 100644
--- a/node_modules/patch-package/dist/makePatch.js
+++ b/node_modules/patch-package/dist/makePatch.js
@@ -109,7 +109,7 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
resolutions: resolveRelativeFileDependencies_1.resolveRelativeFileDependencies(appPath, appPackageJson.resolutions || {}),
}));
const packageVersion = getPackageVersion_1.getPackageVersion(path_1.join(path_1.resolve(packageDetails.path), "package.json"));
- [".npmrc", ".yarnrc", ".yarn"].forEach((rcFile) => {
+ [".npmrc", ".yarnrc", ".yarnrc.yml", ".yarn"].forEach((rcFile) => {
const rcPath = path_1.join(appPath, rcFile);
if (fs_extra_1.existsSync(rcPath)) {
fs_extra_1.copySync(rcPath, path_1.join(tmpRepo.name, rcFile), { dereference: true });
@@ -120,7 +120,7 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
try {
// try first without ignoring scripts in case they are required
// this works in 99.99% of cases
- spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines"], {
+ spawnSafe_1.spawnSafeSync(`yarn`, ["install"], {
cwd: tmpRepoNpmRoot,
logStdErrOnError: false,
});
@@ -128,7 +128,7 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
catch (e) {
// try again while ignoring scripts in case the script depends on
// an implicit context which we haven't reproduced
- spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines", "--ignore-scripts"], {
+ spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--mode=skip-build"], {
cwd: tmpRepoNpmRoot,
});
} |
Seems like there's also a PR open that includes the changes to support Yarn v2+ properly #507 |
after using @topi-identio suggestion I get the error:
|
Use NPM Instead of Yarn npx patch-package --use-npm |
I can't create a patch via npx patch-package, I see an error about the absence of a local file, even though it is in the packages folder
The text was updated successfully, but these errors were encountered: