Skip to content

fix(ffmpeg): windows ffmpeg detection - #6

Merged
dgr8akki merged 2 commits into
dgr8akki:mainfrom
chikof:main
Apr 25, 2026
Merged

dgr8akki merged 2 commits into
dgr8akki:mainfrom
chikof:main

Conversation

@chikof

@chikof chikof commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor
  • Add nix flake for development (thank me later nix devs)
  • Fix Windows ffmpeg detection: probe next to executable with .exe suffix instead of relying solely on PATH
  • Ran go mod tidy

This PR fixes #1

It seems that Go behaves strangely on Windows. To get it to find the binary file in the directory where nano-ffmpeg is run, you have to explicitly tell it to search the current directory: exec.LookPath("./ffmpeg"). This was the only way I could get it to work without having to make any modifications, which isn't the right way to do it.

Shout out to @ulysses-ck for helping me test on windows

- Add nix flake for development (thank me later nix devs)
- Fix Windows ffmpeg detection: probe next to executable with .exe
suffix instead of relying solely on PATH
- Ran `go mod tidy`
@vercel

vercel Bot commented Apr 17, 2026

Copy link
Copy Markdown

@chikof is attempting to deploy a commit to the Aakash Pahuja's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ulysses-ck

Copy link
Copy Markdown

LGTM!!!!

@dgr8akki

Copy link
Copy Markdown
Owner

Thanks @chikof — nice work on the Windows detection fix 🙌 Tested locally: build is clean and existing tests still pass. A few things I'd like to see before merging, plus some smaller suggestions.

Must-address

1. Windows branch short-circuits all other fallbacks

if runtime.GOOS == "windows" {
    return findNextToExecutable(name, ".exe")
}

This returns immediately on Windows whether the lookup succeeds or fails, so fallbackBinaryPaths is permanently unreachable there. Could we make it additive instead?

if runtime.GOOS == "windows" {
    if p, err := findNextToExecutable(name, ".exe"); err == nil {
        return p, nil
    }
}

That way we can add Windows-specific fallbacks (chocolatey, winget, C:\ffmpeg\bin, …) to fallbackBinaryPaths later without another refactor.

2. Regression: fileExists accepts non-executables
Previously the Unix fallbacks used exec.LookPath(p), which also checks the executable bit. os.Stat accepts any regular file (or even a directory). Suggest at minimum:

func fileExists(path string) bool {
    info, err := os.Stat(path)
    return err == nil && info.Mode().IsRegular()
}

…and ideally keep exec.LookPath for the Unix fallback branch.

3. Error loses context
fmt.Errorf("not found next to executable") drops the binary name and candidate path, so the wrapped error reads ffmpeg binary not found: not found next to executable. Please include name (and ideally the resolved exePath) in the message.

Suggestions

  • filepath.EvalSymlinks failure is currently fatal — a soft fallback to the unresolved exePath would be more robust.
  • findNextToExecutable(name, suffix) is only ever called with ".exe". Either inline the suffix or make it OS-agnostic and call it on Linux/macOS too (useful for portable installs).
  • No tests for findNextToExecutable / fileExists. A small test using a temp dir + stubbed executable path would lock in the behaviour.

Nix flake

Happy to have a dev flake, but a couple of things:

  • flakelight-go.url = "github:chikof/flakelight-go" pins to your personal fork. Could we point at an upstream source, or scope the Nix bits under nix/ and document them as optional so the project doesn't take a hard dependency on a single-maintainer repo?
  • Worth double-checking that go.version = 26 actually resolves to Go 1.26.x on a clean machine — we don't want it silently falling back to an older toolchain that disagrees with go.mod.

Nits

  • go.sum gain of golang.org/x/exp is legitimate (transitive via cobra) — re-ran go mod tidy and it stays, no action needed.
  • Promoting bubbletea / lipgloss / cobra to direct require is correct 👍

Happy to approve once #1–#3 are addressed.

@chikof

chikof commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Nix flake

Happy to have a dev flake, but a couple of things:

* `flakelight-go.url = "github:chikof/flakelight-go"` pins to your personal fork. Could we point at an upstream source, or scope the Nix bits under `nix/` and document them as optional so the project doesn't take a hard dependency on a single-maintainer repo?

* Worth double-checking that `go.version = 26` actually resolves to Go 1.26.x on a clean machine — we don't want it silently falling back to an older toolchain that disagrees with `go.mod`.

The nix flake has no impact on the project itself; it is intended solely for development purposes. Therefore, if another Nix developer notices, for example, that the Go version has changed, they can update it in the nix flake and that's it.

@dgr8akki
dgr8akki merged commit c11a937 into dgr8akki:main Apr 25, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: does not find ffmpeg

3 participants