Open shaunek-hero opened 2 months ago
Potentially Related: #12882
Using v1.1.25 on MacOS 14.5, I patched a few files in the dist/lib/builder folder of a package and then received an error when committing the patch:
error: failed applying patch file: EACCES: dist/lib/builder: Permission denied (mkdir())
It created the patch successfully. The error happens when trying to apply the patch. It seems to be doing something in the cwd. It added a dist
folder in my top-level folder. Running ls
on that folder gives an error:
% ls dist
ls: fts_read: Permission denied
It created the folder with 644 permissions instead of 755. If I chmod 755 dist
and then run bun i
again, it fails again with the same error. But now I have a dist/lib folder with 644 permissions. If I jump ahead and create all of the folders that were modified in the package in my project's top-level cwd with proper 755 permissions and run bun i
, the patch is applied without error. I can then delete the dist folder and bun i
continues to run without error due to having cached the patched package.
Interesting @rmarscher. I tried out your steps and replicated.
I guess a difference in your use case vs mine is that in my case the package already had a dist/some-dir
directory and bun patch commit wouldn't let me create any files in that dir (although I could edit files in the same dir), and in your case the package didn't even have a dist
directory to start with and weirdly bun patch commit tried to create directories within your project directory instead of in the package itself. Seems like these could be related but could be slightly different bugs I suppose?
Still seeing this on MacOS with bun version 1.1.27-canary.62
Also seeing this on 1.1.30
What version of Bun is running?
1.1.21+70ca2b76c
What platform is your computer?
Darwin 23.5.0 arm64 arm
What steps can reproduce the bug?
Add any package that has multiple levels of directories, this specific test is with the
typescript
package. Add a random file to any existing directory in the package that is two levels deep.What is the expected behavior?
After running the
bun patch --commit
command there should be no error, and the file that was created (ienode_modules/typescript/lib/es/test.txt
) should be in place.What do you see instead?
Shell output is like this:
It did successfully edit the
package.json
file and it created this patch file:However, when it attempts to apply the patch file it fails. Repeated attempts to delete the package and run
bun install
result in the sameerror: failed applying patch file: EACCES: lib/es: Permission denied (mkdir())
error.Additional information
When I try to add a file to the root of the package (ie,
node_modules/typescript/
) or to a subdirectory (ie,node_modules/typescript/lib
) it seems to work just fine. This only seems to arise when the file is being added to a directory multiple levels deep. Note that editing files that are multiple levels deep works fine as well, it is only when creating a new file.I've replicated this problem on a couple of different packages so far. My actual target package is called
qbo
and interestingly on that package I am able to add a file within thenode_modules/qbo/src/entities/
dir, but I cannot add any files to thenode_modules/qbo/dist/entities
dir nor can I add to thenode_modules/qbo/dist/lib
dir.A couple additional notes:
pnpm patch
and it worked without a problem.patch -p1 < typescript@5.5.4.patch
and that worked without a problem.