wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.59k stars 1.24k forks source link

exec.Command() with docker not working in builds, but work in wails dev #3103

Open MarkBerube opened 12 months ago

MarkBerube commented 12 months ago

Description

Looks to be once the application is packaged on Mac OS, it cannot perform any docker calls on exec.Command() but work perfectly fine if called from wails dev

To Reproduce

1: Start a project: wails init -n test_project -t svelte-ts

2: Go to app.go and change the Greet function to be the following:

// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {

    cmd := exec.Command("docker", "container", "ls")
    out, err := cmd.Output()

    if err == nil {
        return string(out)
    }

    return fmt.Sprintf("Nop", name)
}

3: Run wails dev on the project

4: Click the "Greet" button. You'll see it runs docker container ls successfully with output.

5: Run wails build on the project and open your project binaries in the /build dir.

6: Run step 4, but notice it no longer outputs docker container ls. Error 2 on runtime

Expected behaviour

Docker calls to work in builds outside of wails dev

Screenshots

Screenshot 2023-12-06 at 10 16 03 AM Screenshot 2023-12-06 at 10 16 29 AM

Attempted Fixes

Tried the docker calls from a Makefile, no dice.

Tried to use /bin/sh -c, also no dice.

System Details

# Wails
Version | v2.6.0

# System
┌─────────────────────────┐
| OS           | MacOS    |
| Version      | 13.6.1   |
| ID           | 22G313   |
| Go Version   | go1.20.3 |
| Platform     | darwin   |
| Architecture | amd64    |
└─────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version         |
| Xcode command line tools  | N/A          | Installed | 2397            |
| Nodejs                    | N/A          | Installed | 20.9.0          |
| npm                       | N/A          | Installed | 10.1.0          |
| *Xcode                    | N/A          | Installed | 15.0.1 (15A507) |
| *upx                      | N/A          | Available |                 |
| *nsis                     | N/A          | Available |                 |
└─────────────────────── * - Optional Dependency ────────────────────────┘


### Additional context

_No response_
leaanthony commented 12 months ago

More likely an issue with permissions. Check if there's a plist value you can change. This really isn't anything to do with Wails.

MarkBerube commented 12 months ago

@leaanthony nah, plist wise it looks good, binaries match up. It runs, Mac considers the plist valid, no X on it as well. I even tried the following what the dev plist did to no avail.

What ended up working was running the binary directly in App -> Contents -> MacOS -> App. Just worked out of the box. Ever see that before?

leaanthony commented 12 months ago

It's certainly a bundle permission issue in that case.

Try this: https://groups.google.com/g/golang-nuts/c/Ul1XsHm5I2s?pli=1