wails icon indicating copy to clipboard operation
wails copied to clipboard

Wails build creating invalid folders based on embed file selections. Then failing.

Open precisionpete opened this issue 1 year ago • 7 comments
trafficstars

Description

I have a strange problem where the "wails build" process is creating folders with illegal names based on files I am embedding. The embed commands are not part of the wails app but are in another package in my project.

handlers/render.go contains:
//go:embed assets/*
var assetsFs embed.FS
//go:embed *.gohtml
//go:embed layouts/*.gohtml
var templateFs embed.FS

Wails build creates folders with those name 'assets/*', '*.gohtml', etc. with a file gitkeep in them. It's either wails or some component used by wails.

Then, it fails to compile due to those existing. It is definitely wails build that is creating them. I delete them and they show up again.

$ find .|grep '*'
./cmd/prog/package/handlers/*.gohtml
./cmd/prog/package/handlers/*.gohtml/gitkeep
./cmd/prog/package/handlers/layouts/*.gohtml
./cmd/prog/package/handlers/layouts/*.gohtml/gitkeep
./cmd/prog/package/handlers/assets/*
./cmd/prog/package/handlers/assets/*/gitkeep

To Reproduce

Just running wails build in my project root. It worked fine for months and just started.

$ wails build
Wails CLI v2.8.1
# Build Options
Platform(s)        | linux/amd64                                               
Compiler           | /usr/local/go/bin/go                                      
Skip Bindings      | false                                                     
Build Mode         | production                                                
Devtools           | false                                                     
Frontend Directory | /home/pcarroll/Development/Golang/netrinos-client/frontend
Obfuscated         | false                                                     
Skip Frontend      | false                                                     
Compress           | false                                                     
Package            | true                                                      
Clean Bin Dir      | false                                                     
LDFlags            |                                                           
Tags               | []                                                        
Race Detector      | false                                                     

# Building target: linux/amd64
  • Generating bindings:   ERROR   
          cmd/prog/package/handlers/render.go:27:12: pattern *.gohtml: cannot embed directory *.gohtml: invalid name *.gohtml
          exit status 1
  ERROR   
          cmd/prog/edgenode/handlers/render.go:27:12: pattern *.gohtml: cannot embed directory *.gohtml: invalid name *.gohtml          
          exit status 1

Expected behaviour

It just compiles on Windows and used to on Linux

Screenshots

No response

Attempted Fixes

I delete the folders, delete the build folder. It all comes back.

System Details

On Linux 22.04 amd64 with Wails 2.8.1 and Go 1.22.2 it fails. Same on Windows 11 works fine as before.


$ wails doctor

                                
          Wails Doctor          
                                

                                                                                                                           
# Wails
Version         | v2.8.1
Package Manager | apt   

# System
┌───────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Linux Mint                                                             |
| Version      | 21.3                                                                   |
| ID           | linuxmint                                                              |
| Go Version   | go1.22.2                                                               |
| Platform     | linux                                                                  |
| Architecture | amd64                                                                  |
| CPU          | Intel(R) Core(TM) i7-8700T CPU @ 2.40GHz                               |
| GPU          | CoffeeLake-S GT2 [UHD Graphics 630] (Intel Corporation) - Driver: i915 |
| Memory       | 66GB                                                                   |
└───────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Available | 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.44.0-0ubuntu0.22.04.1 |
| npm        | npm                   | Installed | 10.2.4                  |
| *nsis      | nsis                  | Installed | v3.08-2                 |
| pkg-config | pkg-config            | Installed | 0.29.2-1ubuntu3         |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - docker: sudo apt install docker.io

 SUCCESS  Your system is ready for Wails development!

Additional context

Please give me some hints on how to debug this...

precisionpete avatar Apr 26 '24 23:04 precisionpete

It seems this is an issue with how Wails generates a list of embedded files, the pattern matching syntax your external packages use is perfectly valid and it should match the associated files instead of looking for a directory with asterisks and whatnot.

TwoNull avatar Apr 27 '24 19:04 TwoNull

@precisionpete As we don't have your project to reproduce, could you please do a git bisect to determine which commit started doing this. AFAIK there has been no code updates to creating directories in a long time so I'm curious.

leaanthony avatar Apr 27 '24 21:04 leaanthony

I don't use git on this one. Git is installed (thus the gitignore files). But I've not been committing things regularly.

I think what changed was I combined the handlers and templates into the same folder. I was spending too much time going back and forth between two folders. This required adding the *.gohtml selection. I was working on the Windows version of the app at the time and all was well. When I went back to Linux, it started happening. I did not try it on macos.

To continue to get work done, I separated the handlers and templates folders again, and it all worked. It also works on macros.

So, maybe this bug has been there for a while? It would be interesting to know if it's wails or vite doing it. I'm using wails with sveltekit.

The handlers are not used in the wails part of the app. I have another daemon that uses them. And even though the embeds are not "within" the wails app's context, they are in a package under the overall project.

My application is a daemon that runs as root and a Wails front end that sits under a systray icon. Wails does not interact with http.

Personally, I suspect some of the external tools wails is using in its build.

precisionpete avatar Apr 28 '24 13:04 precisionpete

Please try the above PR to see if this fixes your problem. If you are unsure how to do this, please follow this guide. Let us know how you get on 👍

leaanthony avatar Apr 29 '24 07:04 leaanthony

@precisionpete ☝️

leaanthony avatar Apr 30 '24 10:04 leaanthony

Sorry, I have been nose down trying to meet a deadline. I will have to come back to it if its okay? A few days,

precisionpete avatar Apr 30 '24 13:04 precisionpete

That seems to have fixed it on Linux.

It's also fixed on macOS.

I never had the problem on Windows...

Thanks for the fix. Great product!

precisionpete avatar May 01 '24 15:05 precisionpete