Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feat compose convertion windows support#384

Open
Arka-cell wants to merge 4 commits into
Eldara-Tech:mainfrom
Arka-cell:feat-compose-convertion-windows-support
Open

Feat compose convertion windows support#384
Arka-cell wants to merge 4 commits into
Eldara-Tech:mainfrom
Arka-cell:feat-compose-convertion-windows-support

Conversation

@Arka-cell
Copy link
Copy Markdown

@Arka-cell Arka-cell commented Jun 3, 2026

Compose to Swarm Stack conversion results in the following error:

⚠ editor failed: exec: "nano": executable file not found in %PATH%  

To mitigate this error, I updated the default editor fallback logic.

In the codebase, when the EDITOR environment variable is not defined, the application was hardcoded to fall back to "nano". Since Windows does not have nano installed by default, running operations that spawn an editor (such as configuring services, stacks, or secrets) fails with the error you saw: exec: "nano": executable file not found in %PATH%.

What I did to fix it:

I modified the editor selection logic in the following files:

views/stacks/editcmd.go
views/configs/editcmd.go
views/secrets/actions.go

For each file, the logic has been updated to check the OS environment using Go's standard runtime package:

It first looks up the EDITOR environment variable.
If empty, it checks the standard fallback VISUAL.
If both are empty, it checks if the current OS is Windows (runtime.GOOS == "windows"). If so, it falls back to the built-in GUI editor notepad. Otherwise, it defaults to nano.

Here is an example of the updated logic now in place:

	editor := os.Getenv("EDITOR")
	if editor == "" {
		if runtime.GOOS == "windows" {
			editor = "notepad"
		} else {
			editor = "nano"
		}
	}

Since notepad is standard on every Windows machine, SwarmCLI will now launch Notepad when you trigger stack edit actions, allowing you to edit the compose templates smoothly without any extra configuration.

@clangenb
Copy link
Copy Markdown
Collaborator

clangenb commented Jun 5, 2026

Thanks for tackling the Windows editor issue! A few things to address before merge:

  1. views/configs/editcmd.go is missing the VISUAL fallback. This file only got the runtime.GOOS == "windows" branch — it doesn't add the os.Getenv("VISUAL") step that stacks/editcmd.go and secrets/actions.go received. The PR description says VISUAL is checked everywhere, so this looks like a copy-paste miss. It now behaves differently from its siblings:
  editor := os.Getenv("EDITOR")
  if editor == "" {
      editor = os.Getenv("VISUAL") // <-- missing here
  }
  if editor == "" {
      if runtime.GOOS == "windows" {
          editor = "notepad"
      } else {
          editor = "nano"
      }
  }
  1. The resolution logic is now duplicated across three files (and already drifting). With EDITOR → VISUAL → OS-default, this is non-trivial enough to warrant a single helper rather than three copies. Suggest extracting it to a shared package (e.g. core/primitives/editor, next to the existing hash package) and calling it from all three sites. This PR already touches all
    three, so it's a good moment to unify.

  2. No tests. Once extracted, the helper is straightforward to cover with a table-driven test: EDITOR set / VISUAL set / both empty, crossed with runtime.GOOS being windows vs. otherwise.

  3. views/secrets/actions.go doesn't split editor args. It calls exec.Command(editor, tmp.Name()) directly, whereas stacks and configs do strings.Fields(editor) first. So EDITOR="code --wait" works in stacks/configs but breaks in secrets. Pre-existing, but a shared helper (point 2) would fix it for free.

Nitpick: I think the title is wrong, the change is editor-fallback, not compose-conversion-specific.

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.

2 participants