Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wails dev: Unable to start application #2277

Closed
aiwaki opened this issue Jan 7, 2023 · 10 comments
Closed

wails dev: Unable to start application #2277

aiwaki opened this issue Jan 7, 2023 · 10 comments
Labels
Bug Something isn't working

Comments

@aiwaki
Copy link

aiwaki commented Jan 7, 2023

Description

PS E:\app\src> wails dev       
DEB | Using go webview2loader
Wails CLI v2.3.1

Executing: go mod tidy        
  • Generating bindings: Done.
  • Installing frontend dependencies: Done.
  • Compiling frontend: Done. 

> frontend@1.0.0 dev
> vite

Port 5173 is in use, trying another one...
Port 5174 is in use, trying another one...

  VITE v3.2.5  ready in 777 ms

Vite Server URL: http://localhost:5175/
  ➜  Local:   http://localhost:5175/
  ➜  Network: use --host to expose
Running frontend DevWatcher command: 'npm run dev'
Building application for development...
  • Generating bindings: Done.
  • Generating application assets: Done.
  • Compiling application: Done.
 INFO  Wails is now using the 
new Go WebView2Loader. If you 
encounter any issues with it, 
please report them to https://
github.com/wailsapp/wails/issu
es/2004. You could also use th
e old legacy loader with `-tag
s native_webview2loader`, but 
keep in mind this will be deprecated in the near future.    

FATAL: Unable to start applica
tion: fork/exec E:\app\s
rc\cmd\build\bin\app-dev.exe:
 %1 is not a valid Win32 application.

To Reproduce

  1. Run wails dev
  2. Wait for the build
  3. See the error:
FATAL: Unable to start applica
tion: fork/exec E:\app\s
rc\cmd\build\bin\app-dev.exe:
 %1 is not a valid Win32 application.

Expected behaviour

Normal behavior

Attempted Fixes

I'm completely confused. The application is automatically deleted from the build folder, but I can't determine at what exact moment this deletion occurs

System Details

wails doctor:

DEB | Using go webview2loader
Wails CLI v2.3.1

Scanning system - Please wait 
(this may take a long time)...Done.

# System

OS           | Windows 10 Pro 

Version      | 2009 (Build: 22000)
ID           | 21H2           

Go Version   | go1.18.3       

Platform     | windows        

Architecture | amd64          


# Wails

Version | v2.3.1

# Dependencies

Dependency | Package Name | Status    | Version
WebView2   | N/A          | Installed | 108.0.1462.54       
npm        | N/A          | Installed | 8.12.1
*upx       | N/A          | Installed | upx 3.96
*nsis      | N/A          | Available |
* - Optional Dependency       

# Diagnosis

Your system is ready for Wails development!
Optional package(s) installation details:
  - nsis : More info at https:
//wails.io/docs/guides/windows-installer/

Additional context

Sorry to bother you, but I really can't figure out what's wrong

@aiwaki aiwaki added the Bug Something isn't working label Jan 7, 2023
@stffabi
Copy link
Collaborator

stffabi commented Jan 7, 2023

Thanks for using Wails and reporting this issue.

Never seen that error before, this seems like the build Go binary is not valid. Found one open issue on Golang golang/go#54564
FATAL: Unable to start application: fork/exec E:\app\src\cmd\build\bin\app-dev.exe: %1 is not a valid Win32 application.

A couple of question to hopefully narrow that down.

  • Does this also happen with a newly initialzed wails init -n myproject project?
  • Does it also occur when you try to start a production build created by wails build --debug?

@aiwaki
Copy link
Author

aiwaki commented Jan 7, 2023

* Does this also happen with a newly initialzed `wails init -n myproject` project?

No, it doesn't happen

* Does it also occur when you try to start a production build created by `wails build --debug`?

When I launch the application, I get the error message "This app can't run on your PC"

I recently upgraded to v2.3.1
I also slightly changed the structure of the project and wails.json, but it seems to me that it shouldn't cause this error

@stffabi
Copy link
Collaborator

stffabi commented Jan 7, 2023

Thanks for getting back with this information.

If it doesn't happen with a clean project, then it seems like some combination of options and your code in combination with Wails is somehow triggering this error. I've found the following issue on Golang golang/go#54564. But that seems a very limited case when this happens.

I recently upgraded to v2.3.1

Could you try downgrading to an older version to see if that solves the issue? What version did you use before?

@stffabi
Copy link
Collaborator

stffabi commented Jan 7, 2023

I'm very interested to find the root cause of this issue.

@aiwaki
Copy link
Author

aiwaki commented Jan 7, 2023

Could you try downgrading to an older version to see if that solves the issue? What version did you use before?

I used v2.2.0, installed it now, but it didn't solves the issue. Now I'm also very interested

@aiwaki
Copy link
Author

aiwaki commented Jan 7, 2023

I found out why this error is happening, but I need help solving it

If I add absolutely any thing from any package to main, then this error occurs:

package main

import (
	"embed"
	"app/cmd"
	"app/internal/utils"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {
        // Example
	utils.True() // "This app can't run on your PC"

	cmd.Run(&assets)
}

utils:

func True() bool {
	return true
}

The error occurs not only with functions, but also with anything else (variables, etc.)

It is noteworthy that when I build a project without wails, using go build, then everything is fine

@stffabi
Copy link
Collaborator

stffabi commented Jan 8, 2023

That's interesting. Did you use all needed build tags when building with 'go build'? Wails uses some special build tags. You could use 'wails build -v 2' to see a verbose log output with the used go build command.

Did you try to update go?

@aiwaki
Copy link
Author

aiwaki commented Jan 8, 2023

I just updated Go to the go1.19.4 windows/amd64 version and everything is fine now. I didn't understand anything, but okay. Thanks for the help!

@stffabi
Copy link
Collaborator

stffabi commented Jan 8, 2023

So that looks like a go compiler bug.
Maybe you could also test if the latest go 1.18 patch release does fix it too.

@stffabi
Copy link
Collaborator

stffabi commented Jan 8, 2023

Great you got it working.

As it seems to be a compiler bug, I think we could close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants