-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Self update under windows issues. #115
Comments
Hi @slyshykO thanks for creating this issue, can you supply your |
This is my config. The store_directory is set to $HOME/bin. |
Are you on WSL? I did not know windows also had a $HOME environment variable. For future reference, this is their config file
|
@slyshykO
|
@MitchellBerend |
Mhh okay I don't know enough about windows to help with that, is there a common way to do self update on windows? Edit: a quick google search tells me others get around this by renaming their currently running program so there is no name collision. Is this something that is easy to do? |
I wasn't aware Windows has such a problem 😮 I don't know how to fix it, this requires some investigation. Any help is appreciated! 🙏🏻 |
Searching for answers, I think trying to support this on Windows might not be feasible without increasing complexity. My suggestion is to warn users on Windows that
|
So, I've asked about the potential solution on Twitter and, apparently, there's a simple way. Windows doesn't allow updating the executable while it's running. However (and this is weird) it allows renaming it (by moving to a different directory or just changing a name). So, the simple solution to this problem seems to be following:
So, yes, this logic should be only on Windows (conditional compilation) and only for |
For what it's worth, here's my understanding of why this happens: Linux/unix has a concept of "unlinking" rather than "deleting" files. This basically removes the file from the directory tree, but it doesn't delete the file object (inode1) in the kernel or free the file's data on disk until all open file descriptors are closed and hard links are unlinked. Basically each inode has a reference count consisting of all open file descriptors and all hard links (including the hard link you might consider the original path to the file). This means you can unlink the executable file for a running process on unix without the actual inode being deleted yet. Windows doesn't really have this concept of unlinking. There is The reason why renaming works is because you're not actually deleting the underlying file data, you're just moving it to a new location in the directory tree. This doesn't require special permissions since it does not remove the file from disk. My current workaround is this powershell script: # tool-sync.ps1
$local:ErrorActionPreference = 'Stop'
$currentToolPath = (Get-Command tool).Source
$newToolDir = "$env:TEMP/$((New-Guid).Guid)"
$newToolPath = "$newToolDir/tool.exe"
mkdir $newToolDir > $null
Copy-Item $currentToolPath $newToolDir
& $newToolPath sync
Remove-Item -Force -Recurse $newToolDir Footnotes |
Is anybody currently working on this? If not, I'd be happy to take it on. |
Actually, I just set this up on Linux for the first time, and self update doesn't seem to be working there either. I'm getting |
I'll try and test this on my machine, I haven't actually self updated yet so I'm not sure. |
@binyomen It doesn't actually work for me either. If what you are saying is the case the ci needs to be changed as well so it does not give a false positive.
|
Sorry for the radio silence on this. I can work on both self update in unix and windows then. |
A self_replace crate for this task might be able to resolve this now. |
Is it possible to sync the tool from the tool under windows?
I am getting the error:
The text was updated successfully, but these errors were encountered: