[PR #1389] Fix Windows reload issue (/bin/sh not found) #5701

Closed
opened 2026-03-01 15:42:20 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/0xJacky/nginx-ui/pull/1389

State: closed
Merged: Yes


This PR adds native Windows compatibility for Nginx-UI, fixing the following error when reloading Nginx on
Windows:

Nginx error: exec: "/bin/sh": executable file not found in %PATH%

Updated execShell in internal/nginx/exec.go
to use cmd /C instead of /bin/sh -c when running on Windows.

This makes ReloadCmd, RestartCmd, and other Nginx commands work properly on Windows environments.

Implementation Detail

func execShell(cmd string) (stdOut string, stdErr error) {
    if runtime.GOOS == "windows" {
        return execCommand("cmd", "/C", cmd)
    }
    return execCommand("/bin/sh", "-c", cmd)
}

Added import "runtime" for OS detection.

Tested Environment

OS: Windows 10 / Windows Server 2019

Nginx: Windows build (nginx.exe)

Result:

Reload and Restart work correctly

UI responds successfully

No /bin/sh errors

**Original Pull Request:** https://github.com/0xJacky/nginx-ui/pull/1389 **State:** closed **Merged:** Yes --- This PR adds native Windows compatibility for Nginx-UI, fixing the following error when reloading Nginx on Windows: ``` Nginx error: exec: "/bin/sh": executable file not found in %PATH% ``` Updated execShell in internal/nginx/exec.go to use cmd /C instead of /bin/sh -c when running on Windows. This makes ReloadCmd, RestartCmd, and other Nginx commands work properly on Windows environments. # Implementation Detail ``` go func execShell(cmd string) (stdOut string, stdErr error) { if runtime.GOOS == "windows" { return execCommand("cmd", "/C", cmd) } return execCommand("/bin/sh", "-c", cmd) } ``` Added import "runtime" for OS detection. # Tested Environment OS: Windows 10 / Windows Server 2019 Nginx: Windows build (nginx.exe) Result: Reload and Restart work correctly UI responds successfully No /bin/sh errors
kerem 2026-03-01 15:42:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#5701
No description provided.