self_update icon indicating copy to clipboard operation
self_update copied to clipboard

I keep ending up with a 0 byte executable

Open Nickhoyer opened this issue 3 years ago • 10 comments

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. image

Nickhoyer avatar Jan 18 '22 12:01 Nickhoyer

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.

jaemk avatar Jan 22 '22 01:01 jaemk

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

Screenshot 2022-04-19 173419

Going to the "new exe download url" shows

Screenshot 2022-04-19 173603

So maybe this is the problem? I have no idea lol

andrew121410 avatar Apr 19 '22 21:04 andrew121410

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

jaemk avatar Apr 19 '22 23:04 jaemk

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.

jaemk avatar Apr 19 '22 23:04 jaemk

This works

Screenshot 2022-04-19 214414

Screenshot 2022-04-19 214903

andrew121410 avatar Apr 20 '22 01:04 andrew121410

Now this actually works. I'm beyond confused

Screenshot 2022-04-19 215816

andrew121410 avatar Apr 20 '22 02:04 andrew121410

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?

jaemk avatar Apr 20 '22 04:04 jaemk

Yes replacing it with this still replaces it with an empty binary

A4592734-24DB-4052-8354-3DCFB1473A9E

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

CAF10A1B-9464-4281-B821-A2CAA13882A0

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

412CAEB0-7682-46B9-859F-8A0905A6C2EC

andrew121410 avatar Apr 20 '22 04:04 andrew121410

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

jaemk avatar Apr 20 '22 23:04 jaemk

Is there a way to configure self_update to not extract?

CheatCod avatar Jul 18 '23 06:07 CheatCod