self_update
self_update copied to clipboard
I keep ending up with a 0 byte executable
I tried changing my main function from async to sync, I tried running as admin, running in a different folder, closing the app after updating, but every time, it looks to be correctly downloading a 13.2MB file from github, but then without warnings, it replaces my local exe with a 0 byte file that will never run.
Is there anything I can do to avoid this? I didn't see it mentioned in other issues. I'm on windows, and so is my ci runner.

hey @Nickhoyer , could you try using some variation of the code in the docs here https://github.com/jaemk/self_update/blob/cf0a017f058bbeaf63ad680ff8c5a60513efad8c/src/lib.rs#L92 and tell it to move the downloaded/extracted file to some location that isn't the current exe? I'm wondering if it's something related to exe replacement on windows.
Same, I keep getting 0 bytes. Even when specifying a new location that's not the same location of the executable it's still 0 bytes. Not sure how to fix it, and I'm on Linux(Ubuntu Server)
Looking at the photo Nickhoyer posted it's not a download link for a executable, but a page with JSON on it. If that makes sense?
For an example here's mine

Going to the "new exe download url" shows

So maybe this is the problem? I have no idea lol
The github api returns json to basic get requests. You have to set Accept: application/octet-stream to get back the contents of the release (which happens here):
james@tamale|t.main:~/bin$
::: curl -LO https://api.github.com/repos/andrew121410/Limonium/releases/assets/63040612
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1561 100 1561 0 0 10518 0 --:--:-- --:--:-- --:--:-- 11150
james@tamale|t.main:~/bin$
::: file 63040612
63040612: JSON data
::: curl -LO https://api.github.com/repos/andrew121410/Limonium/releases/assets/63040612 -H 'Accept: application/octet-stream'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 10.0M 100 10.0M 0 0 20.3M 0 --:--:-- --:--:-- --:--:-- 20.3M
james@tamale|t.main:~/bin$
::: file 63040612
63040612: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ca974c7e079f34babf7575cd2a2e5fd8022e662b, for GNU/Linux 3.2.0, with debug_info, not stripped
It'd be helpful if you could modify your code to use the example code linked to in https://github.com/jaemk/self_update/issues/81#issuecomment-1019003981, modify the final Move::from_source to write to some other file, and then check if that file has the full contents. My guess is it's something to do with replacing the current binary, but I'm unable to reproduce it myself.
This works


Now this actually works. I'm beyond confused

That's... Interesting. And if you replace the contents of that update function with a call to the GitHub updater, then it spits out an empty file again?
Yes replacing it with this still replaces it with an empty binary

I just realized it’s probably not working correctly because I’m not utilizing self_update correctly in update.rs it calls this

My only asset is just a binary not a archive like a .zip etc

Ah, yeah that'll do it! Glad you were able to get to the bottom of it. Maybe it was the same thing affecting @Nickhoyer
Is there a way to configure self_update to not extract?