Plugin can't find files when there are round brackets in the path: C:\Program Files (x86)\Jenkins\workspace\ProjectName\STG\src\web
More details:
Plugin version: 4.5.1
Config:
new CopyWebpackPlugin([
{
from: '../config_app/web.config',
},
],
{debug: 'debug'}
)
If project is located in c:\temp\test (x86)\ folder, nothing is copied.
Logs:
95% emitti 95% emitting CopyPlugin[copy-webpack-plugin] starting emit
[copy-webpack-plugin] processing from: '../config_app/web.config' to: ''
[copy-webpack-plugin] determined '' is a 'dir'
[copy-webpack-plugin] determined '../config_app/web.config' to be read from 'c:\
temp\test (x86)\config_app\web.config'
[copy-webpack-plugin] begin globbing 'c:/temp\test (x86)\config_app\web.config
' with a context of 'c:\temp\test (x86)\config_app'
[copy-webpack-plugin] finishing emit
112ms emitting
98% after 98% after emitting CopyPlugin[copy-webpack-plugin] starting after-em
it
[copy-webpack-plugin] adding c:\temp\test (x86)\config_app\web.config to change
tracking
[copy-webpack-plugin] finishing after-emit
If I rename folder to c:\temp\test\ everything is ok.
Logs:
95% emitti 95% emitting CopyPlugin[copy-webpack-plugin] starting emit
[copy-webpack-plugin] processing from: '../config_app/web.config' to: ''
[copy-webpack-plugin] determined '' is a 'dir'
[copy-webpack-plugin] determined '../config_app/web.config' to be read from 'c:\
temp\test\config_app\web.config'
[copy-webpack-plugin] begin globbing 'c:/temp\test\config_app\web.config' with a
context of 'c:\temp\test\config_app'
[copy-webpack-plugin] found c:/temp/test/config_app/web.config
[copy-webpack-plugin] determined that 'c:/temp/test/config_app/web.config' shoul
d write to 'web.config'
[copy-webpack-plugin] reading c:\temp\test\config_app\web.config to write to ass
ets
[copy-webpack-plugin] added c1d3d3f388cb75b70467b9c4ac56a90b to written tracking
for 'c:\temp\test\config_app\web.config'
[copy-webpack-plugin] writing 'web.config' to compilation assets from 'c:\temp\t
est\config_app\web.config'
[copy-webpack-plugin] finishing emit
110ms emitting
98% after 98% after emitting CopyPlugin[copy-webpack-plugin] starting after-em
it
[copy-webpack-plugin] adding c:\temp\test\config_app\web.config to change tracki
ng
[copy-webpack-plugin] finishing after-emit
Is this a bug or I'm doing something wrong?
@igoralemasow can you create minimum reproducible test repo?
@evilebottnawi here it is https://github.com/igoralemasow/Reproduce-round-bracket-bug-in-copy-webpack-plugin
/cc @loveky regression? or bug?
Got it. I'll check this issue this weekend.
@evilebottnawi maybe it's time for a new release? :smiley: The latest version 4.5.1 was released on Mar 9 so it doesn't contain my fix.
@loveky i.e. you fix also fix this problem?
@evilebottnawi yes.
you can verify that by the following steps:
clone the reproduct repo and npm install
uninstall copy-webpack-plugin 4.5.1 by npm uninstall --save-dev copy-webpack-plugin
install the latest version from github repo by:
npm install --save-dev git+https://[email protected]/webpack-contrib/copy-webpack-plugin.git
@igoralemasow you can also verify this in your production repo.
@loveky it workes, thank you! Will wait for a new release on npm.
Fixed in https://github.com/webpack-contrib/copy-webpack-plugin/releases/tag/v4.5.2, feel free to feedback
This issue can be still reproduced if the root folder consists round brackets in its name.
For example:
d:\Github\Reproduce-round-bracket-bug-in-copy-webpack-plugin\with (round brackets) - OK
d:\with (round brackets) - NOT OK
/cc @loveky
Hi guys, sorry for the late reply.
I checked this issue today and seems it is a bug in node-glob.
See same issue here: https://github.com/isaacs/node-glob/issues/290
I have created a PR for it https://github.com/isaacs/node-glob/pull/373
Looks like the PR has conflicts. Any idea if/when these will be resolved?
Problem in node-glob https://github.com/webpack-contrib/copy-webpack-plugin/issues/266#issuecomment-403492087
I met the same issue and checked it today.
I found the reason why this plug can not copy the files that has "(x86)" in the directory.
In the source "utils/normalize.js",
const absoluteContext = path
.resolve(context)
**.replace(/[\*|\?|\!|\(|\)|\[|\]|\{|\}]/g, (substring) =>[${substring}]);**
With this part, the file path changes like below example.
C:\\Program Files (x86)\\Jenkins\\ --> C:\\Program Files [(]x86[)]\\Jenkins\\
It causes the empty file list in the code "processPattern.js".
return globby(pattern.glob, globOptions).then((paths) =>
Promise.all(
paths.map((from) =>
limit(() => {
@YounHoyoul can you create minimum reproducible test repo?
@evilebottnawi Okay. Let me have a look.
@evilebottnawi I made a simple repo.
https://github.com/YounHoyoul/testwebpackcopyplugin.git
You need to run this in the folder "Test (x86)". I tested in my Mac and Window server. It works in my Mac, but it doesn't work in the Windows server.
Below is the log in windows server.
`
C:\Test (x86)\testwebpackcopyplugin>npm run build
[email protected] build C:\Test (x86)\testwebpackcopyplugin
webpack --config webpack.config.js
Hash: 5b90c629ada6fed12c59
Version: webpack 4.39.3
Time: 113ms
Built at: 09/03/2019 11:52:49 AM
Asset Size Chunks Chunk Names
main.js 3.77 KiB main [emitted] main
Entrypoint main = main.js
[./src/index.js] 0 bytes {main} [built]
`
Below is the log in my Mac,
`
➜ test-copy-webpack-plugin git:(master) npm run build
[email protected] build /Users/luisyoun/Projects/test/Test (x86)/test-copy-webpack-plugin
webpack --config webpack.config.js
Hash: 5b90c629ada6fed12c59
Version: webpack 4.39.3
Time: 75ms
Built at: 09/03/2019 11:57:28 AM
Asset Size Chunks Chunk Names
../target/test.txt 21 bytes [emitted]
main.js 3.77 KiB main [emitted] main
Entrypoint main = main.js
[./src/index.js] 0 bytes {main} [built]
`
As you can see, the log in the windows server doesn't have "../target/test.txt 21 bytes [emitted]" in my Mac.
@YounHoyoul thanks for repo!
Any update on a fix for this? We have the same problem on our build server that is installed at C:\Program Files (x86)\Jenkins.
@cakidnyc maybe you can create reproducible test repo too?
I also just came across the very same error that @YounHoyoul describes here: https://github.com/webpack-contrib/copy-webpack-plugin/issues/266#issuecomment-527015083.
If someone could explain what the purpose of the replace in utils/normalize.js https://github.com/webpack-contrib/copy-webpack-plugin/blob/cc550421455edc722b6a6be2719f97eaa1c426f7/src/utils/normalize.js#L16 is, I would be happy to try and find a fix.
Tobias
Yes, normalize is strange for me too, feel free to investigate it and send a PR
Will do. But since this code was originally meant to actually fix the exact same issue I am a bit confused. Need to trace back whether the original fix would have worked in this scenario.
Fixed in master, release will be soon, if you encounter a problem after updating to 6.0.0 feel free to open a new issue with reproducible test repo, thanks for the issue
Most helpful comment
This issue can be still reproduced if the root folder consists round brackets in its name.
For example:
d:\Github\Reproduce-round-bracket-bug-in-copy-webpack-plugin\with (round brackets) - OK
d:\with (round brackets) - NOT OK