Skip to content

BUG: matcha update fails with permission denied when writing temp binary to /usr/local/bin #1249

@OverStyleFR

Description

@OverStyleFR

Describe the bug

When running the matcha update command as a standard user, the update fails because it attempts to create the temporary binary file directly in the installation directory (/usr/local/bin/), which requires root privileges.

To reproduce

Steps to Reproduce:

  1. Have matcha installed in a directory that requires root privileges (e.g., /usr/local/bin).
  2. Run the update command as a standard user: matcha
  3. The download starts but fails at the file creation step.

Actual Behavior

The updater tries to write the temp file directly to the target directory and throws a permission error:
Plaintext

> matcha update
Current version: 0.36.1
Latest version: 0.37.0
Found release asset: matcha_0.37.0_linux_amd64.tar.gz
Downloading...
update failed: could not create temp binary in target dir: open /usr/local/bin/matcha.new.1778155730: permission denied

Expected behavior

Expected Behavior / Proposed Solution

Instead of attempting to write directly to the protected target directory, it would be more logical for the updater to:

Download the temporary file to `/tmp/`.

Then, either prompt the user for `sudo` privileges to move the binary into `/usr/local/bin/`, or exit gracefully with a clear message instructing the user to run the update command with `sudo` (e.g., Please run 'sudo matcha update`').

Environment

OS: Fedora 43

Matcha Version: 0.36.1 (updating to 0.37.0)

Screenshots

Image

Matcha version

0.36.1

Go version

1.25.9

OS

Linux

OS version

Fedora 43

Architecture

amd64 (x86_64)

Terminal

Kitty

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch/amd64amd64 / x86_64bugSomething isn't workingneeds-responseWaiting on issue author replyneeds-triageAwaiting maintainer reviewos/linuxLinux-specific

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions