Skip to content

wg create: infinite loop when file exists #4665

@abitrolly

Description

@abitrolly

Describe the bug

When specifying config for wireguard tunnel, if the file exists, the command enters an endless loop that can not be interrupted or killed.

touch wgvpn.conf
fly wg create personal ams wgvpn wgvpn.conf
  • fly version

flyctl v0.3.217 linux/amd64 Commit: a6da01f BuildDate: 2025-11-14T20:30:19Z

** Command output: **

$ fly wg create personal ams wgvpn /tmp
Creating WireGuard peer "wgvpn" in region "ams" for organization personal

!!!! WARNING: Output includes private key. Private keys cannot be recovered !!!!
!!!! after creating the peer; if you lose the key, you'll need to remove    !!!!
!!!! and re-add the peering connection.                                     !!!!
Can't create '/tmp': open /tmp: file exists
Can't create '/tmp': open /tmp: file exists
Can't create '/tmp': open /tmp: file exists
Can't create '/tmp': open /tmp: file exists
Can't create '/tmp': open /tmp: file exists
Can't create '/tmp': open /tmp: file exists
Can't create '/tmp': open /tmp: file exists

There is a one liner fix to return the error here.

https://github.com/superfly/flyctl/blob/a6da01fd0840f18fb5c57c66e6335aba85dd08f9/internal/command/wireguard/others.go#L75C7-L75C14

But the code looks a bit messy, so I decided to make it more readable first #4664

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions