Hi guys
I am create installer for electron based application. After statrting installation I got this error:
2015-12-31 02:42:13> Program: Starting Squirrel Updater: --download http://localhost:8080
2015-12-31 02:42:14> Program: Fetching update information, downloading from http://localhost:8080
2015-12-31 02:42:14> SingleGlobalInstance: Failed to grab lockfile, will retry: C:\Users\Kronos\AppData\Local\Temp.squirrel-lock-9EE16BB6874851C3999012BDB96FCD82CB46EF2E: System.IO.IOException: Process can't access file "C:\Users\Kronos\AppData\Local\Temp.squirrel-lock-9EE16BB6874851C3999012BDB96FCD82CB46EF2E", this file used by another process.
胁 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
胁 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
胁 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
胁 Squirrel.SingleGlobalInstance..ctor(String key, TimeSpan timeOut)
I am having the same issue, has anyone encountered this/is aware of a workaround?
Is it being used by another process?
Having the same issue. I'm not able to update my apps...
Same issue here. Similar to previous issues #138 and #189
Most of these ended up being developer error (I.e. the error being thrown is correct) - how are you calling it?
I have the same issue. I'm using it in the context of Electron (version 0.36.7) . I wonder if it's because I'm periodically calling autoUpdater.checkForUpdates(); and it's not releasing the underlying process.. I might dig into it a little if I have time.. https://github.com/atom/electron/commit/fae2c7bc7a129e86b17e8222b61e3c6aca96afbd
@fantasticsid It could also very well be that your timer is actually running into itself - i.e. update can sometimes take a long time as we download a bunch of stuff, and you're firing it a 2nd time while the 1st one runs
We check every 15 minutes, against a local server, should be fine.. However we do start checking immediately right after the app starts. So if the Update.exe process is not killed and we restart, we could run into the problem. Now I don't know if Update.exe is reclaimed when the Electron process quits. But from what I see it just spawns an external process, so it's possible.
Are you seeing this on initial install or periodically at other times?
I lost track. If it only happens on initial install, then I assume I'm not handling squirrel events well. I'm using 'electron-squirrel-startup'.
I checked however that I don't start auto updater for initial install.
I just tried again, seems it only happens on initial install.
This is the module I'm using to handle squirrel events.
https://github.com/mongodb-js/electron-squirrel-startup/blob/master/index.js
My electron main file is something like:
start() {
if (require('electron-squirrel-startup')) return;
// initialization
// auto updater setup
}
start();
So the module does not seem handle --squirrel-install correctly in that it does not wait for the external process to terminate, before returning.
So this might be what happens:
This is the only thing I can think of..
I can just try spawnSync to see if that's the case..
I don't think using spawnSync solves the problem. Still seeing the same error.
However if I delay checking for auto updates, it succeeds and does not report the 'cannot grab lock file' error. That's weird because I think using spawnSync to wait for update.exe should allow it to release the lock file..
@fantasticsid did you find the root cause? I'm using the similar code, but didn't handle electron-squirrel-startup events (didn't require this module), fails on --download event.
2016-03-24 11:53:33> Program: Starting Squirrel Updater: --download http://localhost:3000/releases/win32/0.0.2
2016-03-24 11:53:33> Program: Fetching update information, downloading from http://localhost:3000/releases/win32/0.0.2
2016-03-24 11:53:33> SingleGlobalInstance: Failed to grab lockfile, will retry: C:\Users\Uladzimir_Havenchyk\AppData\Local\Temp\.squirrel-lock-644163BA75DFB804D06745BECE472F7629EBDAF0: System.IO.IOException: The process cannot access the file 'C:\Users\Uladzimir_Havenchyk\AppData\Local\Temp\.squirrel-lock-644163BA75DFB804D06745BECE472F7629EBDAF0' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
/cc @paulcbetts
I haven't looked into it unfortunately.
Is there a fix for this yet? I'm always getting this error on the initial install of my application :(
@mzmousa This isn't a bug, if you see this you are doing something incorrect, like checking for updates in a squirrel hook or right after startup
Ah, I am indeed checking for updates right after startup - before my app is ready. Is there a recommended time to call checkForUpdates() ? And should I be doing checks to make sure it's not being called more than once?
I read this issue and you commented saying to do checkForUpdates in --squirrel-firstrun. I will try that.
@mzmousa you can this try https://github.com/electron/electron/pull/6037/files
Thanks @havenchyk , but you could you be more specific? I tried inserting that code instead of the code where I handle squirrel events, but it gave me the exact some problems as before.
Nevermind. I wasn't calling autoUpdater.checkForUpdates in the right place. I was running it before my app finished loading. I'm calling it like this now and I don't get the Failed to grab lockfile issue when I startup the app :tada:
myBrowserWindow.webContents.once("did-frame-finish-load", function (event) {
autoUpdater.checkForUpdates();
})
@mzmousa I think it's a side effect of delaying the call to checkForUpdates, the app is expected to wait a few seconds for squirrel to release the lock on first run.
I can't install Microsoft Teams and this is the log:
2017-07-25 16:18:57> Program: Starting Squirrel Updater: --install .
2017-07-25 16:18:57> Program: Starting install, writing to C:\Users\van.ly\AppData\Local\SquirrelTemp
2017-07-25 16:18:57> UpdateManager: using rootAppDirecotry: C:\Users\van.ly\AppData\Local\Microsoft\Teams
2017-07-25 16:18:57> Program: About to install to: C:\Users\van.ly\AppData\Local\Microsoft\Teams
2017-07-25 16:18:57> SingleGlobalInstance: Failed to grab lockfile, will retry: C:\Users\van.ly\AppData\Local\Temp\2\.squirrel-lock-819EA015A6DB1B7BEE0615FE75BABA5A6BB0B631: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\van.ly\AppData\Local\Temp\2\.squirrel-lock-819EA015A6DB1B7BEE0615FE75BABA5A6BB0B631'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Squirrel.SingleGlobalInstance..ctor(String key, TimeSpan timeOut)
However, when I tried to create the folder 2 within Temp folder, the installer finished successfully.
I have fixed changing environment variables which are temp and tmp . If one of these paths are incorrect , you get this error.
I can't install Microsoft Teams and this is the log:
2017-07-25 16:18:57> Program: Starting Squirrel Updater: --install . 2017-07-25 16:18:57> Program: Starting install, writing to C:\Users\van.ly\AppData\Local\SquirrelTemp 2017-07-25 16:18:57> UpdateManager: using rootAppDirecotry: C:\Users\van.ly\AppData\Local\Microsoft\Teams 2017-07-25 16:18:57> Program: About to install to: C:\Users\van.ly\AppData\Local\Microsoft\Teams 2017-07-25 16:18:57> SingleGlobalInstance: Failed to grab lockfile, will retry: C:\Users\van.ly\AppData\Local\Temp\2\.squirrel-lock-819EA015A6DB1B7BEE0615FE75BABA5A6BB0B631: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\van.ly\AppData\Local\Temp\2\.squirrel-lock-819EA015A6DB1B7BEE0615FE75BABA5A6BB0B631'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Squirrel.SingleGlobalInstance..ctor(String key, TimeSpan timeOut)However, when I tried to create the folder 2 within Temp folder, the installer finished successfully.
This solution saved my day.
@shiftkey original issue was resolved, this can be closed.
Most helpful comment
I can't install Microsoft Teams and this is the log:
However, when I tried to create the folder 2 within Temp folder, the installer finished successfully.