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

Closed
opened 2026-02-26 12:11:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/0xJacky/nginx-ui/pull/1389
Author: @Alireza-Gholiei
Created: 10/12/2025
Status: Merged
Merged: 10/12/2025
Merged by: @0xJacky

Base: devHead: fix/windows-exec-shell


📝 Commits (1)

  • bc3ef78 fix: support Windows in execShell by replacing /bin/sh with cmd.exe

📊 Changes

1 file changed (+16 additions, -1 deletions)

View changed files

📝 internal/nginx/exec.go (+16 -1)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/0xJacky/nginx-ui/pull/1389 **Author:** [@Alireza-Gholiei](https://github.com/Alireza-Gholiei) **Created:** 10/12/2025 **Status:** ✅ Merged **Merged:** 10/12/2025 **Merged by:** [@0xJacky](https://github.com/0xJacky) **Base:** `dev` ← **Head:** `fix/windows-exec-shell` --- ### 📝 Commits (1) - [`bc3ef78`](https://github.com/0xJacky/nginx-ui/commit/bc3ef78e4278ffa4e2ce93175f56061fa5248fe6) fix: support Windows in execShell by replacing /bin/sh with cmd.exe ### 📊 Changes **1 file changed** (+16 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/nginx/exec.go` (+16 -1) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 12:11:02 +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#1270
No description provided.