-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
The process cannot access the file because it is being used by another process. #28
Comments
Hi, which command do you use to run the script? |
I face the same situation when for the first attempt of calling ./serve (windows/powershell/administrator). Running in a separate shell command generated the certificate files and then full error stack. Generating certificates... Certificates path: C:\Users\username\AppData\Roaming\https-localhost. Never modify nor share this files. Downloading the mkcert executable... http to https redirection active. Running mkcert to generate certificates... (node:5160) UnhandledPromiseRejectionWarning: Error: Command failed: "C:\Users\username\AppData\Roaming\https-localhost\mkcert-v1.4.1-windows-amd64.exe" -install -cert-file "C:\Users\username\AppData\Roaming\https-localhost\localhost.crt" -key-file "C:\Users\username\AppData\Roaming\https-localhost\localhost.key" localhost The process cannot access the file because it is being used by another process. at ChildProcess.exithandler (child_process.js:294:12) at ChildProcess.emit (events.js:182:13) at maybeClose (internal/child_process.js:962:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5) (node:5160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:5160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. { [Error: ENOENT: no such file or directory, open 'C:\"C:\Users\username\AppData\Roaming\https-localhost\mkcert.log"'] errno: -4058, code: 'ENOENT', syscall: 'open', path: 'C:\\"C:\\Users\\username\\AppData\\Roaming\\https-localhost\\mkcert.log"' } { [Error: ENOENT: no such file or directory, open 'C:\"C:\Users\username\AppData\Roaming\https-localhost\mkcert.err"'] errno: -4058, code: 'ENOENT', syscall: 'open', path: 'C:\\"C:\\Users\\username\\AppData\\Roaming\\https-localhost\\mkcert.err"' } |
Hi @camous, |
serve wasn't able to works with the error (I tested) beside the process was hanging. I have the feeling the mkcert crashed/hang for some reasons (I was in administrator) making the promise fails. when running mkcert manually (from command line directly), I think I remember I had a dialog box asking me to install the certificate in my local store (sorry I don't have the screen). maybe this dialog box on my windows version/laptop from works made the promise fails ? |
Okay, thanks for the further investigation! I suspect the error is within this promise, but I'm running out of time in these days. In any case, thank you for your time and for the precise information you already provided! |
little bit short on time, however, will quickly check if I can remove the installed certificate in order to re-produce the issue. that would be a first step :) |
I'm seeing the same thing.
|
This may fix issue #28 but requires more tests on Windows
Hi guys, I've opened a branch for investigating the problem. I found path formatting error on macOS. I fixed on darwin architectures (see the above commit), but I need to test it on Windows. Anyway, probably the cause it will be the same. |
@robokozo @camous # uninstall any version of https-localhost (if any)
npm i -g https-localhost
# install the fixed version directly from the GitHub branch
npm install -g git://github.com/daquinoaldo/https-localhost.git#fix-issue-28 It should work. # uninstall any version of https-localhost (if any)
npm i -g https-localhost
# clone the fix-issue-28 branch of this repository
git clone -b fix-issue-28 https://github.com/daquinoaldo/https-localhost
# if you don't have git just download [this zip](https://github.com/daquinoaldo/https-localhost/archive/fix-issue-28.zip) and unzip it
# move into the folder
# should work also on Windows, but anyway, just open a terminal inside the directory you have cloned/downloaded
cd https-localhost
# install dependencies
npm i
# run tests
npm t
# if tests fail please paste here the output and run them again, second time should work
npm t Troubleshooting: try to delete those two folders (it is safe, they are created by my script). Then try to install it or to run tests again.
Thanks for your time, I really appreciate it. EDIT: just a couple of notes.
|
I ran the tests and this is the result:
|
Thanks @robokozo! |
Yes, I'm afraid so |
I've ran other tests and even after many attempts I still unable to reproduce the issue. I tried to investigate the causes, but I can't find any parallelization errors: I await all the needed promises and call sync APIs on fs, the code is almost sequential. |
Hi, probably not much help but I'm getting the same error on windows with your 'fix-issue-28' version. And as others have mentioned running the exact same command mentioned in the error manually works correctly strangely. |
Hey, probably you know it but, I npm installed the I'm running Windows Insider: 20226.1000. Node.js: v14.12.0 For me, the version on npm produces the following error on first run.
After installing the certificate in C:\Users\Janice\AppData\Roaming\https-localhost, running serve with npm version works perfectly. |
Hi @NoelJacob, The error at first run happens only with the public version, the latest release on npmjs.org, and not with the If so, publishing the fix branch on npm should fix at least the missing file problem (i.e. the wrong path construction bug). |
yes it should fix the problem |
Have the same problem. So, I cloned
|
Hi @yakunins (and @Xeonzinc, @robokozo, @camous), could you please try again on
I'm still not be able to reproduce the bug. I remove the log files (1574929). That should fix the Any further suggestion, feedback or other contribution is welcome. |
hey @daquinoaldo , sorry for not answering before :/ however, followed your instruction and it works for me. however is it exactly from an exact vanilla computer ? I will try on my other computer just after. |
Fix issue #28: the file is being used by another process on Windows
Thank you, guys! |
@daquinoaldo Thank you, tests are passed. |
By the way, the fix has been released in v4.6.3. |
These are the logs:
Generating certificates...
[0] Certificates path: C:\Users\roberto.rodriguez\AppData\Roaming\https-localhost.
[0] Downloading the mkcert executable...
[0] Running mkcert to generate certificates...
[0] (node:13992) UnhandledPromiseRejectionWarning: Error: Command failed: C:\Users\roberto.rodrigu4.exe -install -cert-file C:\Users\roberto.rodriguez\AppData\Roaming\https-localhost\localhost.crtocalhost\localhost.key localhost
[0] The process cannot access the file because it is being used by another process.
[0]
[0] at ChildProcess.exithandler (child_process.js:294:12)
[0] at ChildProcess.emit (events.js:182:13)
[0] at maybeClose (internal/child_process.js:962:16)
The text was updated successfully, but these errors were encountered: