wailsapp / wails

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

no `index.html` could be found in your Assets fs.FS #3048

Open precisionpete opened 11 months ago

precisionpete commented 11 months ago

Description

I have an app that used to work but now I am getting noindex.htmlcould be found in your Assets fs.FS, please make sure the embedded directory '.' is correct and contains your assets.

wails dev works fine but wails build produces the error. I assume this means its not something in my code?

To Reproduce

Using my specific app. Run:

wails dev --> it works

wails build build/bin/myapp

2023/11/10 10:12:01 no index.html could be found in your Assets fs.FS, please make sure the embedded directory '.' is correct and contains your assets

It works fine with the example app.

Expected behaviour

the build should work

Screenshots

No response

Attempted Fixes

I tried changing the order of embeds, same problem.

I tested on macOS & Windows and it fails there too.

System Details

Wails Doctor          

# Wails
Version         | v2.6.0
Package Manager | apt   

# System
┌───────────────────────────┐
| OS           | Linux Mint |
| Version      | 21.2       |
| ID           | linuxmint  |
| Go Version   | go1.21.1   |
| Platform     | linux      |
| Architecture | amd64      |
└───────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Installed | 24.0.5-0ubuntu1~22.04.1 |
| gcc        | build-essential       | Installed | 12.9ubuntu3             |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.33-1ubuntu2        |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.42.1-0ubuntu0.22.04.1 |
| npm        | npm                   | Installed | 10.1.0                  |
| *nsis      | nsis                  | Installed | v3.08-2                 |
| pkg-config | pkg-config            | Installed | 0.29.2-1ubuntu3         |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
 SUCCESS  Your system is ready for Wails development!

Additional context

I'm sure it has something to do with the build timing. I am looking for suggestions for debugging at this point.

Interestingly, Wails Dr identifies Go 1.21.1 but I am using Go 1.21.4. Where is it getting this from? I have had a few strange transient problems similar to this...

precisionpete commented 11 months ago

I think I solved it. I had moved the App.go code into a separate package to avoid having to make calls into main. I think this messed up the go embedding. When I returned it to the main package, the problem stopped. I suspect it worked in wails dev because of the asset handler doing the job of the embedding.

I need to go back to the books about how to get stuff in the main package accessible from elsewhere.

leaanthony commented 11 months ago

You can move things around how you want, just update the embed path (has to be a subdirectory of the current). You can even just package the assets in a different package and export if you like.

sgx-wb commented 11 months ago

Hello, I want to call other wails programs, such as https://github.com/yt-dlp/yt-dlp/releases, within the built unix application, but after the build is complete, I can't find the unix file, image image @leaanthony Have you ever tried this operation before? Or do you have any solution? by looking at the size of the wails file, it seems that the unix file has been packaged into the application image

PylotLight commented 11 months ago

@sgx-wb Can you show your main.go file where the embeds are defined? It also looks like you're jumping into an unrelated thread, can you join the discord or create your own issue?

sgx-wb commented 11 months ago

@sgx-wb Can you show your main.go file where the embeds are defined?

@PylotLight I didn't modify main.go. I just modified vite.config.js and added the static folder. image image

PylotLight commented 11 months ago

@sgx-wb have a go at //go:embed frontend/dist frontend/dist/testinstead?

sgx-wb commented 11 months ago

@sgx-wb have a go at //go:embed frontend/dist frontend/dist/testinstead?

@PylotLight https://github.com/wailsapp/wails/issues/3055 I created a new question.

fiendclub commented 9 months ago

I am getting this issue, however my app.go is inside of package main, I am using ReactJs

When running wails dev it works however wails build does not work I get the error: noindex.htmlcould be found in your Assets fs.FS, please make sure the embedded directory 'frontend/dist' is correct and contains your assets

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

leaanthony commented 9 months ago

If you change where your assets are built to, then you'll need to change your //go:embed line to point to the right place

mega-rds commented 5 months ago

wails build command does not seem to compile the UI any longer? image