Skip to content
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

axoupdater probably dumping weird tempdir garbage all over the place on windows #1374

Open
Gankra opened this issue Aug 27, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Gankra
Copy link
Member

Gankra commented Aug 27, 2024

Two things building up on my system:

PATH starts with this huge mess

C:\Users\ninte\AppData\Local\Temp\.tmpgnZRgs\bin;C:\Users\ninte\AppData\Local\Temp\.tmpwuPfF4\bin;C:\Users\ninte\AppData\Local\Temp\.tmpEzIVd6\bin;C:\Users\ninte\AppData\Local\Temp\.tmpIAVvIP\bin;C:\Users\ninte\AppData\Local\Temp\.tmp8odYwJ\bin;C:\Users\ninte\AppData\Local\Temp\.tmpxryyGS\bin;C:\Users\ninte\AppData\Local\Temp\.tmpr3cko9\bin............................

and .cargo is filling up with these:

image

Seemingly the raw powershell installer doesn't have this problem, so I'm forced to conclude this is axoupdater's doing.

@Gankra Gankra added the bug Something isn't working label Aug 27, 2024
@Gankra
Copy link
Member Author

Gankra commented Aug 27, 2024

clarification: this doesn't break anything but is disgusting if you ever notice it

@mistydemeo
Copy link
Contributor

Just had a thought. Does a new one of those appear when you cargo test on axoupdater? The tests are probably leaking changes to your real environment, which we should work harder to disable.

It looks like the shell installer respects a INSTALLER_NO_MODIFY_PATH environment variable, but the PowerShell installer doesn't. It'd be worth unifying that behaviour.

Those temporary directories look like the result of binary relocation we do. Specifically, we relocate the running binary to a temporary directory on the same drive so we can then replace it with the new binary at its original path. This directory is supposed to be deleted when the installation completes, but it looks like that must not be working.

mistydemeo added a commit to axodotdev/axoupdater that referenced this issue Aug 27, 2024
`cargo test` outside CI would end up adding the temporary
directory persistently to user's real dotfiles. Leave this on
in CI because it doesn't hurt anything there.

NOTE: this environment variable isn't supported on Windows at the
moment - we should probably try to unify that behaviour.

Refs axodotdev/cargo-dist#1374.
@mistydemeo
Copy link
Contributor

Just realized what must be happening. It's failing to delete the temporary directory because the running EXE is still in it, so it's leaving the directory and the old version of the EXE in place. This wasn't an issue before when we rooted the temporary directory in the system temp dir, since it would get cleaned up, but after axodotdev/axoupdater#121 the temporary directories are surviving indefinitely.

I feel like I remembered somewhere seeing some kind of Windows rm command that acts after a lock is cleared...

mistydemeo added a commit that referenced this issue Aug 28, 2024
This is supported from the environment in the shell installer, but
was previously only supported on the CLI in the powershell installer.

This will be useful to ensure axoupdater tests don't pollute the
environment: axodotdev/axoupdater#168

refs #1374.
@mitsuhiko
Copy link

I wonder if you could use self_replace. For very selfish reasons. I use it in a few other places and it would be good to collect all these fixes for windows in one central crate :)

@mistydemeo
Copy link
Contributor

I'm looking into self_replace. We have a usecase slightly outside of your expectations since we're performing the replacement in a subprocess, so we can't use the self_replace function directly, but I think we can work something out here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants