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

Cannot extract to C:Temp #657

Closed
sdcote opened this issue Jun 10, 2021 · 2 comments
Closed

Cannot extract to C:Temp #657

sdcote opened this issue Jun 10, 2021 · 2 comments

Comments

@sdcote
Copy link

sdcote commented Jun 10, 2021

This is a cross between a bug and a feature request. Maybe this is more of an FYI.

In some installations, it is not possible to extract an executable to C:\Temp. This could be for various reasons including corporate security policies on the workstation and antivirus schemes.

On our system, using WebDriverManager 4.4.3, we get Access is denied and a stacktrace for a FileNotFoundException:

17:19:02.741 [main] ERROR io.github.bonigarcia.wdm.WebDriverManager - There was an error managing chromedriver 91.0.4472.19 (C:\Temp\5814829277389791627\chromedriver.exe (Access is denied))
java.io.FileNotFoundException: C:\Temp\5814829277389791627\chromedriver.exe (Access is denied)
	at java.io.FileOutputStream.open0(Native Method) ~[?:1.8.0_112]
	at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[?:1.8.0_112]
[snipped]

The contents of the temp directory does not contain any .exe files, only a single .zip file:

Microsoft Windows [Version 10.0.19042.985]
(c) Microsoft Corporation. All rights reserved.

C:\Temp\5814829277389791627>dir
 Volume in drive C is Windows
 Volume Serial Number is 2805-D3C9

 Directory of C:\Temp\5814829277389791627

06/09/2021  05:19 PM    <DIR>          .
06/09/2021  05:19 PM    <DIR>          ..
06/09/2021  05:19 PM         5,857,940 chromedriver_win32.zip
               1 File(s)      5,857,940 bytes
               2 Dir(s)  134,232,215,552 bytes free

C:\Temp\5814829277389791627>

The zip does contain the chromedriver.exe but the extract logic cannot create the file in that location. Again, this could be for a variety of reasons.

After downloading sources and debug tracing we find that org.apache.commons.io.FileUtils.openOutputStream is the source of the exception. This is our stack when the exception is thrown:

open0:native FileOutputStream (java.io)
open:270 FileOutputStream (java.io)
<init>:213, FileOutputStream (java.io)
openOutputStream:2450, FileUtils (org.apache.commons.io)
openOutputStream:2414, FileUtils (org.apache.commons.io)
copyToFile:1041, FileUtils (org.apache.commons.io)
copyInputStreamToFile:951, FileUtils (org.apache.commons.io)
downloadAndExtract:135, Downloader (io.github.bonigarcia.wdm.online)
download:91, Downloader (io.github.bonigarcia.wdm.online)
download:680, WebDriverManager (io.github.bonigarcia.wdm)
manage:593, WebDriverManager (io.github.bonigarcia.wdm)
setup:287, WebDriverManager (io.github.bonigarcia.wdm)
main:10, WebDriverManagerDemo (demo)

Maybe you would consider providing a configuration option for the location of the "temporary" directory?

Not sure if this would solve our problem, but we have seen several references to similar problems with no resolution. Allowing the user to specify their home directory might be a possible solution for some.

@bonigarcia
Copy link
Owner

I have just committed a patch including a configuration key to change the default behavior (i.e., for not using the temporary folder). It will be available for the next release of WebDriverManager.

@bonigarcia
Copy link
Owner

WebDriverManager 5 is out. In this release, you can find the method avoidTmpFolder().

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

2 participants