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

bundleignore doesn't ignore while copying files to temp dir #215

Open
anilanar opened this issue Apr 23, 2022 · 1 comment
Open

bundleignore doesn't ignore while copying files to temp dir #215

anilanar opened this issue Apr 23, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@anilanar
Copy link

anilanar commented Apr 23, 2022

Describe the bug
When there are files that have permissions incompatible with whatever yarn bundle does with them (or yarn/fslib does with them), adding such files to .bundleignore does not help because apparently ignoring happens later on in the pipeline.

In my case, I'm using nix + direnv, which creates a .direnv directory that contains symlinks to readonly files somewhere else on the system. Even if I add .direnv to .bundleignore, yarn bundle copies them to a temp dir and then runs chmod on them, which fails.

To Reproduce
Steps to reproduce the behavior:

  1. cd into a project that uses yarn v2/v3 workspaces
  2. touch ~/bar need a file somewhere else for this reproduction
  3. sudo chown root ~/bar root or any other user, any user other than yours.
  4. sudo chmod 0444 ~/bar make it readonly for everybody.
  5. ln -s ~/bar foo gotta create a symlink for reproduction
  6. Add foo to .bundleignore
  7. cd into a workspace and run yarn bundle.

I think this can also be reproduced by creating a symlink to a non-existing path.

Expected behavior
Everything works fine.

Actual behavior
EPERM: operation not permitted, chmod '<omitted tmp dir path>/foo'

Desktop (please complete the following information):

  • MacOS

Additional info
This could be solved by not even copying ignored dirs/files to a tmp dir for further processing.

@anilanar anilanar added the bug Something isn't working label Apr 23, 2022
@anilanar anilanar changed the title Ignore doesn't ignore while copying files to temp dir bundleignore doesn't ignore while copying files to temp dir Apr 24, 2022
@ojkelly
Copy link
Owner

ojkelly commented May 27, 2022

Yep I think you're correct it's happening too late in the process.

The current process they're deleted after being copied to a tmp directory.

This can probably be solved by using something like fs-extra which has the ability to take in a function to filter files to copy
https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy.md#copysrc-dest-options-callback

it would be replacing this line

await xfs.copyPromise(tmpDir, sourceConfiguration.projectCwd, {

If this feels like something you might be able to work on let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants