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

(BROKEN ON MACOS) Binary files lose executable permissions after copy. #771

Closed
NxRoot opened this issue Mar 24, 2024 · 5 comments
Closed

Comments

@NxRoot
Copy link

NxRoot commented Mar 24, 2024

Binary file execution is completely broken.

This is my code:

new CopyWebpackPlugin({
    patterns: [
      {
        from: path.resolve(__dirname, 'src/main/_py'),
        to: path.resolve(__dirname, '.webpack/main/_py'),
      }
    ]
 })

This will throw an EACCES error every time we try to execute binary files.

The files get copied to the desired folder, however they lose all the permissions to be executed via spawn or exec or any other method to execute them.

I know it is a issue from your plugin because Ive added a delay before executing the files and quickly copied the files manually before they get executed, this way it works but obviously we cant even package the app this way.

I recommend you take a look at this plugin and fix your own plugin.
Thanks

@alexander-akait
Copy link
Member

Duplicate of #35, feel free to send a PR, what we need -

If an asset has stats in its assets info, we will apply some stats before write them, we need send a PR to webpack and send PR here to write them (under the option)

@NxRoot
Copy link
Author

NxRoot commented Mar 25, 2024

Duplicate of #35, feel free to send a PR, what we need -

If an asset has stats in its assets info, we will apply some stats before write them, we need send a PR to webpack and send PR here to write them (under the option)

Don't understand what you are saying, it should be an easy fix.
A simple chmod after copying the files would do it...

var file = "PATH/TO/FILE"

// Get current permissions
var stats = fs.statSync(file)
var currentPermission = '0' + (stats.mode & parseInt('777', 8)).toString(8);

// Set permissions on copied files
fs.chmodSync(file, currentPermission)

@alexander-akait
Copy link
Member

alexander-akait commented Mar 25, 2024

We can't just run fs.chmodSync here, because writting assets is a part of webpack logic, not a plugin

@NxRoot
Copy link
Author

NxRoot commented Mar 25, 2024

We can't just run fs.chmodSync here, because writting assets is a part of webpack logic, not a plugin

Well, the webpack-permissions-plugin is doing a chmodSync as part of plugin code, how come your copy-webpack-plugin is not able to do it since it is meant to copy files?

I can only understand that from a perspective where you dont want to automatically set permissions, thats ok, but...

Is there any chance of adding a new property to the patterns so that the developer can specify permissions to be applied to the copied files?

@alexander-akait
Copy link
Member

Because this plugin is buggy, it uses Node.js fs, but in real usage webpack uses not only Node.js fs, it is possible to use memfs and any other custom fs, this plugin will work for some cases, but it is an invalid solution

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

No branches or pull requests

2 participants