tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] [windows updater] updating tauri apps using updater fails if installed to `C:\Program Files`

Open anatawa12 opened this issue 1 year ago • 1 comments

Describe the bug

Some user of my tauri app want to install the application to C:\Program Files. So, they launched the installer with Administer Privilege by left-clicking the installer exe and the initial installation works well with this method.

However, because the updater doesn't launch the installer with admin privilege, it will indefinitely fails to upgrade the tauri app.

the tauri updater should detect missing privilege and ask user for admin privilege OR ask admin privilege inside the installer if writing file fails with permission error.

Reproduction

  1. install some a little older tauri app into C:\Program Files by launching the installer exe with admin privilege
  2. launch the tauri app without admin privilege and upgrade with tauri updater
  3. upgrading the app fails

You may use my ALCOM for real-world example. 0.1.0-rc.0 can be used as the old version https://github.com/vrc-get/vrc-get/releases/tag/gui-v0.1.0-rc.0

image

Expected behavior

Upgrading the app should not be failed and the update process should ask for admin privilage

Full tauri info output

> [email protected] tauri
> npm install && tauri info


up to date, audited 447 packages in 534ms

136 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.12.2
    - pnpm: 8.15.6
    - yarn: 1.22.19
    - npm: 10.5.0

[-] Packages
    - tauri [RUST]: 1.6.1
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.7
    - tao [RUST]: 0.16.8
    - tauri-cli [RUST]: 2.0.0-beta.11
    - @tauri-apps/api [NPM]: 1.5.3 (outdated, latest: 1.5.4)
    - @tauri-apps/cli [NPM]: 1.5.11 (outdated, latest: 1.5.12)

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: out
    - devPath: http://localhost:3000/
    - framework: React (Next.js)
    - bundler: Webpack

Stack trace

No response

Additional context

No response

anatawa12 avatar Apr 30 '24 08:04 anatawa12

Hmm, @amrbashir feedback is imo more valuable here than mine, but imho it'd be better to simply not allow installing a perUser installer with admin permissions and instead rely on the perMachine mode for that. There's more logic in the installer that expects a perUser installer to be actually be installed for just that user. idk what the best way forward is though.

FabianLars avatar Apr 30 '24 11:04 FabianLars

I agree, perUser installers shouldn't at all interfere with perMachine mode.

amrbashir avatar May 14 '24 02:05 amrbashir

sorry, I'm not good at Windows. What's the perUser installer means? is there any config to enable installing app for machine (not for user?)

anatawa12 avatar May 14 '24 03:05 anatawa12

See https://tauri.app/v1/api/config#nsisconfig.installmode

amrbashir avatar May 14 '24 14:05 amrbashir

Basically perUser will try to install to C:\Users\<user>\AppData\Local (but users can pick another directory) and doesn't require Admin privileges to install, on the other hand, perMachine installs to C:\Program Files by default and requires Admin privileges to install.

There is also both mode which allows the user after starting the installer, to choose between perUser and perMachine

amrbashir avatar May 14 '24 14:05 amrbashir

Sorry, I missed 'installmode' settings. Thank you.

anatawa12 avatar May 15 '24 00:05 anatawa12