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

Creating patch file for GitHub dependency fails with ENOENT: no such file or directory #288

Closed
devattendant opened this issue Feb 7, 2021 · 9 comments · Fixed by #444
Closed

Comments

@devattendant
Copy link

I was trying to create a patch for a GitHub dependency I added to my projects like this in package.json:
"react-native-scrollable-tab-view": "git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"

And creating the patch fails with:

• Diffing your files with clean files
Error: ENOENT: no such file or directory, scandir '/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view'
at Object.readdirSync (node:fs:1067:3)
at Object.klawSync [as default] (/.../react-native/node_modules/klaw-sync/klaw-sync.js:13:25)
at Object.removeIgnoredFiles (/.../react-native/node_modules/patch-package/dist/filterFiles.js:10:24)
at Object.makePatch (/.../react-native/node_modules/patch-package/dist/makePatch.js:123:23)
at /.../react-native/node_modules/patch-package/dist/index.js:48:25
at Array.forEach ()
at Object. (/.../react-native/node_modules/patch-package/dist/index.js:47:22)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32) {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view'
}
/.../react-native/node_modules/patch-package/dist/makePatch.js:184
throw e;
^

Error: ENOENT: no such file or directory, scandir '/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view'
at Object.readdirSync (node:fs:1067:3)
at Object.klawSync [as default] (/.../react-native/node_modules/klaw-sync/klaw-sync.js:13:25)
at Object.removeIgnoredFiles (/.../react-native/node_modules/patch-package/dist/filterFiles.js:10:24)
at Object.makePatch (/.../react-native/node_modules/patch-package/dist/makePatch.js:123:23)
at /.../react-native/node_modules/patch-package/dist/index.js:48:25
at Array.forEach ()
at Object. (/.../react-native/node_modules/patch-package/dist/index.js:47:22)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32) {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/var/folders/bx/qmlnk5tn0lqgn4d_cyplmh5w0000gn/T/tmp-46952lUjIew9dd5Kd/node_modules/react-native-scrollable-tab-view'
}

I then looked a bit into makePatch.js and found the automatically created package.json looking like this:
{"dependencies":{"react-native-scrollable-tab-view":"react-native-scrollable-tab-view@git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"},"resolutions":{}}

So just to check if the react-native-scrollable-tab-view@ is the issue I replaced the getPackageResolution call in makePatch.js:49 with the static GitHub URL I used in the package.json above and the patch file was created correctly:
{"dependencies":{"react-native-scrollable-tab-view":"git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"},"resolutions":{}}

I am now wondering if I am linking the GitHub dependency in a wrong way (though I tried various other) or if this is a bug or not expected usage of patch-package at all.

All of this happened on macOS 11.1 with patch-package 6.2.2.

@devattendant
Copy link
Author

Issue still exists with patch-package 6.4.7 (this time on Windows 10):

npx patch-package react-native-scrollable-tab-view
patch-package 6.4.7
• Creating temporary folder
• Installing [email protected] with npm
{
status: 1,
signal: null,
output: [ null, null, null ],
pid: 40520,
stderr: null,
error: null
}

...\react-native\node_modules\patch-package\dist\makePatch.js:218
throw e;
^
{
status: 1,
signal: null,
output: [ null, null, null ],
pid: 40520,
stdout: null,
stderr: null,
error: null
}

And replacing makePatch.js:50 with the following still works:
fs_extra_1.writeFileSync(tmpRepoPackageJsonPath, JSON.stringify({"dependencies":{"react-native-scrollable-tab-view":"git+https://github.com/ptomasroos/react-native-scrollable-tab-view.git"},"resolutions":{}}));

@patrickjm
Copy link

I also get this issue. My repo has this syntax in package.json:

"somePackage": "github:someAuthor/somePackage#v0.46.5",

@cestef
Copy link

cestef commented Jun 27, 2021

replace makePatch:50 with the following:
fs_extra_1.writeFileSync(tmpRepoPackageJsonPath, JSON.stringify({ dependencies: { [packageDetails.name]: getPackageResolution_1.getPackageResolution({ packageDetails, packageManager, appPath, }).replace(/(.*)@/g, ""), }, resolutions: resolveRelativeFileDependencies_1.resolveRelativeFileDependencies(appPath, appPackageJson.resolutions || {}), }));

it's quite a messy solution, but it still works for me :')

@sebastian-zarzycki-apzumi

Same here. A bit annoying.

@OmgImAlexis
Copy link

@cstefFlexin I'm not really sure what your "fix" is meant todo there as the returned URL is incorrect.

#335 fixes the issue.

@cestef
Copy link

cestef commented Jul 17, 2021

@cstefFlexin I'm not really sure what your "fix" is meant todo there as the returned URL is incorrect.

#335 fixes the issue.

I am just replacing the first part of the git url, it seemed to work, but your solution looks cleaner indeed

@OmgImAlexis
Copy link

@cstefFlexin I'm not really sure what your "fix" is meant todo there as the returned URL is incorrect.
#335 fixes the issue.

I am just replacing the first part of the git url, it seemed to work, but your solution looks cleaner indeed

Oh that makes sense now. I guess with how I was adding the repo your fix wasn't actually doing anything to the returning string.

@alexthewilde
Copy link

This issue still exists. And @cestef's solution seems to fix it.

@nkpm
Copy link

nkpm commented Nov 7, 2022

replace makePatch:50 with the following: fs_extra_1.writeFileSync(tmpRepoPackageJsonPath, JSON.stringify({ dependencies: { [packageDetails.name]: getPackageResolution_1.getPackageResolution({ packageDetails, packageManager, appPath, }).replace(/(.*)@/g, ""), }, resolutions: resolveRelativeFileDependencies_1.resolveRelativeFileDependencies(appPath, appPackageJson.resolutions || {}), }));

it's quite a messy solution, but it still works for me :')

works like a charm. rightaway created a patch for patch-package with patch-package 😵‍💫

dijonkitchen added a commit to dijonkitchen/patch-package that referenced this issue Dec 27, 2022
@orta orta closed this as completed in #444 Dec 28, 2022
stianjensen pushed a commit to stianjensen/patch-package that referenced this issue Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants