rules_js icon indicating copy to clipboard operation
rules_js copied to clipboard

[Bug]: Renaming files isn't respected by patches in patchedDependencies

Open robin-pham opened this issue 1 year ago • 2 comments

What happened?

When creating patch files, if a part of the patch involves re-naming a file, it is not respected and only the file modifications are respected. I've tried using both patchedDependencies in the package.json as well as patches in the npm_translate_lock

Version

Development (host) and target OS/architectures: Apple M2 Pro (I believe this is happening on Mac devices, and not linux devices, as CI machines were not affected by this) See the logs https://github.com/robin-pham/rules_js/actions/runs/5430054761/jobs/9875524119. Similar thing happened with our own setup where local doesn't work but our linux machines in CI work

Output of bazel --version: aspect 5.5.2

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved: JS

How to reproduce

See: https://github.com/aspect-build/rules_js/commit/01d28745052854de1b9948fb006c14f204c6d2da

In the above patch file example, when viewing the bazel-bin/node_modules, the file is accurately modified with the additional comments, but the file preserves the previous filename. When the same patchfile is used in pnpm, the file is actually renamed.

Any other information?

No response

robin-pham avatar Jul 01 '23 08:07 robin-pham

Also potentially related, when no modification is made to any file, and the only contents of the patch file is the rename, e.g:

diff --git a/src/common.js b/src/common.js1234
similarity index 100%
rename from src/common.js
rename to src/common.js1234

Then the error that gets spewed out is:

/private/var/tmp/_bazel_robin.pham/337912500358448872bd50fe9efd2d50/external/npm/BUILD.bazel:18:6: @npm//:npm__debug__4.3.4__w2b4m3xsads6xcjljikht6jcgu_source_directory depends on @npm__debug__4.3.4__w2b4m3xsads6xcjljikht6jcgu//:source_directory in repository @npm__debug__4.3.4__w2b4m3xsads6xcjljikht6jcgu which failed to fetch. no such package '@npm__debug__4.3.4__w2b4m3xsads6xcjljikht6jcgu//': Error applying patch @//subdir:patches/[email protected]:
  I can't seem to find a patch in there anywhere.

robin-pham avatar Jul 01 '23 08:07 robin-pham

Thanks for posting this! I have been chewing my head out for the last few days because I couldn't seem to get a patch file to apply through pnpm and seeing your post made me realize the issue was likely that I was deleting a file in my patch.

Just tested it an sure enough! Patching a set of changes that don't include deleting a file gets the patch to work. This was really confusing because the errors were telling me that the file I was trying to delete didn't exist. So it made me think that somehow my changes might've been getting double-patched (once through pnpm and again through bazel).

Great to finally know that's the issue, but it would be great to have this fixed

cfife-btig avatar Sep 05 '23 22:09 cfife-btig