You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
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.
Thanks for tackling the Windows editor issue! A few things to address before merge:
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:
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compose to Swarm Stack conversion results in the following error:
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:
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:
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.