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

Won't find files when there are round brackets () in the path #266

Closed
igoralemasow opened this issue Jun 15, 2018 · 25 comments
Closed

Won't find files when there are round brackets () in the path #266

igoralemasow opened this issue Jun 15, 2018 · 25 comments

Comments

@igoralemasow
Copy link

igoralemasow commented Jun 15, 2018

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?

@alexander-akait
Copy link
Member

@igoralemasow can you create minimum reproducible test repo?

@igoralemasow
Copy link
Author

@alexander-akait
Copy link
Member

/cc @loveky regression? or bug?

@loveky
Copy link
Contributor

loveky commented Jun 15, 2018

Got it. I'll check this issue this weekend.

@loveky
Copy link
Contributor

loveky commented Jun 17, 2018

@evilebottnawi maybe it's time for a new release? 😃 The latest version 4.5.1 was released on Mar 9 so it doesn't contain my fix.

@alexander-akait
Copy link
Member

@loveky i.e. you fix also fix this problem?

@loveky
Copy link
Contributor

loveky commented Jun 19, 2018

@evilebottnawi yes.

you can verify that by the following steps:

  1. clone the reproduct repo and npm install

  2. uninstall copy-webpack-plugin 4.5.1 by npm uninstall --save-dev copy-webpack-plugin

  3. install the latest version from github repo by:

npm install --save-dev git+https://git@github.com/webpack-contrib/copy-webpack-plugin.git

@igoralemasow you can also verify this in your production repo.

@igoralemasow
Copy link
Author

@loveky it workes, thank you! Will wait for a new release on npm.

@alexander-akait
Copy link
Member

@igoralemasow
Copy link
Author

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

@alexander-akait
Copy link
Member

/cc @loveky

@loveky
Copy link
Contributor

loveky commented Jul 9, 2018

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: isaacs/node-glob#290

I have created a PR for it isaacs/node-glob#373

@alexemmons
Copy link

Looks like the PR has conflicts. Any idea if/when these will be resolved?

@alexander-akait
Copy link
Member

Problem in node-glob #266 (comment)

@YounHoyoul
Copy link

YounHoyoul commented Sep 2, 2019

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(() => {

@alexander-akait
Copy link
Member

@YounHoyoul can you create minimum reproducible test repo?

@YounHoyoul
Copy link

@evilebottnawi Okay. Let me have a look.

@YounHoyoul
Copy link

@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

test-copy-webpack-plugin@1.0.0 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

test-copy-webpack-plugin@1.0.0 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.

@alexander-akait
Copy link
Member

@YounHoyoul thanks for repo!

@cakidnyc
Copy link

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.

@alexander-akait
Copy link
Member

@cakidnyc maybe you can create reproducible test repo too?

@tschach
Copy link

tschach commented Mar 12, 2020

I also just came across the very same error that @YounHoyoul describes here: #266 (comment).

If someone could explain what the purpose of the replace in utils/normalize.js

.replace(/[\*|\?|\!|\(|\)|\[|\]|\{|\}]/g, (substring) => `[${substring}]`);
is, I would be happy to try and find a fix.

Tobias

@alexander-akait
Copy link
Member

Yes, normalize is strange for me too, feel free to investigate it and send a PR

@tschach
Copy link

tschach commented Mar 12, 2020

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.

@alexander-akait
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants