wails
wails copied to clipboard
sh: vite: command not found
Description
Hi 👋, thanks for your work on Wails and for maintaining this open source project 💪
I'm getting a sh: vite: command not found
error when running wails build
or wails dev
in a Wails project directory. I saw the related issue https://github.com/wailsapp/wails/issues/1611, but it's closed and sounds like it's related to Svelte only? The project I'm working on is from the vanilla template. I tried to reproduce it with a new project in an empty directory and fresh Git repo, but that didn't work. I think the difference is that I'm working in an existing Git repo which is kind of a monorepo, so maybe in some upper directories some node_modules
or so already exist.
Below I added the reproduction steps, which mimic the steps I did that lead to the issue, although as I mentioned in an empty repo this doesn't lead to the issue.
To Reproduce
- Create temp directory to play in:
mkdir /tmp/wails-repro && cd /tmp/wails-repro
- Create a Git repo:
git init myrepo && cd myrepo
- Check:
git status
looks good 👌
- Check:
- Go is managed globally, but Node is managed by asdf, so add it:
asdf local nodejs latest
-
go version
yieldsgo version go1.20.2 darwin/arm64
,asdf current nodejs
yieldsnodejs 19.8.1 /tmp/wails-repro/myrepo/.tool-versions
,which node
indicates the ASDF shim, andnode --version
yieldsv19.8.1
-
- Make sure to have the latest Wails:
go install github.com/wailsapp/wails/v2/cmd/[email protected]
- Wails check:
wails doctor
- All dependencies are installed, or the optional ones available, and it says "Your system is ready for Wails development!"
- Init Wails project:
wails init -n mygui -t vanilla
- Oops it's in a subdirectory, we'd like to have it in the root of the repo:
mv mygui/** . && mv mygui/.** .
- (the latter for the
.gitignore
) - Check:
ll mygui
, it's empty,ll .
, all files are here
- (the latter for the
-
rm -r mygui
- Let's try the build:
wails build
- No errors, looks good 👌
- Let's try the dev mode:
wails dev
- GUI launches and works, all good 👌
- Commit:
git add . && git commit -a -m "foo"
- Now we're switching to another branch in the monorepo to work on something else. A ton of files are now marked as untracked, because the
.gitignore
from the Wails init is not there yet. We discard all files withgit clean -f .
. To mimick that in these repro steps we just delete the ignored files:rm -r frontend/dist/** && rm -r frontend/node_modules
- Git status is fine, the deleted files were ignored anyway:
git status
👌
- Git status is fine, the deleted files were ignored anyway:
- Can we build the project?
wails build
- ⚠️ Error:
main.go:11:12: pattern all:frontend/dist: cannot embed directory frontend/dist: contains no embeddable files
- This actually reproduces properly. There's a
gitkeep
file so at least for other people checking out the branch with the project they shouldn't run into this issue. But during development in a monorepo, when switching branches to one without the Wails project, the gitkeep doesn't exist yet so whengit clean -f .
ing the repo, the frontend/dist repo is fully gone
- ⚠️ Error:
- Maybe there's something wrong in the order or commands executed, or it's the chicken and egg problem, where the JS part relies on Go for the bindings, but Go relies on the JS stuff in assets. Let's mitigate that with a dummy file:
touch frontend/dist/foo
- Try again:
wails build
- ⚠️ Different error now:
sh: vite: command not found
+exit status 127
- This doesn't reproduce in a fresh empty repo
- ⚠️ Different error now:
Expected behaviour
With wails build
and wails dev
working before, I expected them to still work, despite the deleted files, as the deleted files are all gitignored anyway.
Screenshots
No response
Attempted Fixes
No response
System Details
$ wails doctor
Wails CLI v2.4.1
Scanning system - Please wait (this may take a long time)...Done.
# System
OS | MacOS
Version | 13.2.1
ID | <redacted>
Go Version | go1.20.2
Platform | darwin
Architecture | arm64
# Wails
Version | v2.4.1
# Dependencies
Dependency | Package Name | Status | Version
Xcode command line tools | N/A | Installed | 2396
npm | N/A | Installed | 9.5.1
*Xcode | N/A | Installed | 14.2 (<redacted>)
*upx | N/A | Installed | upx 4.0.2
*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/
♥ If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony
Additional context
I think the major difference is that the Wails project where I'm having the issue is inside an existing Git repository with a lot of existing code and other files.
I have a workaround that fixes the issue temporarily:
- In the problematic project directory, delete all frontend files:
rm -r frontend/**
- It's maybe a bit drastic. Maybe deleting node_modules or one of the other subdirectories is enough. Haven't checked yet.
-
In a different directory create a fresh Wails vanilla project:
cd /tmp && wails init -n mygui -t vanilla && cd mygui
- Copy the frontend files to the problematic directory:
mv frontend/** /path/to/problematic/mygui/frontend/
- In the problematic directory, discard the changes that Git tracks:
cd /path/to/problematic/mygui && git restore .
- As well as delete any files that the init generates but you don't want to have in your project, like the
logo-universal.png
etc:git clean -f .
- Then
wails build
works
Bash one-liner for that:
CWD=$(pwd) WAILS_PROJECT_NAME=$(basename $(pwd)); rm -r frontend/**; cd /tmp; wails init -n ${WAILS_PROJECT_NAME} -t vanilla; cd ${WAILS_PROJECT_NAME}; mv frontend/** ${CWD}/frontend/; cd ${CWD}; git restore .; git clean -f .
I have same problem, cant build wails app
I have two better workarounds.
first:
1.delete dist
folder in frontend
second:
1.add empty file to dist
, name don`t matter. File are going to be removed
This can by caused by generating golang bindings for javascript.
1.wails is compiling golang program
2.wails is generating frontend
3.wails is compiling golang againg
If the steps that I showed are true, this mean that if dist
is empty first stage of compiling will fail, beacuse go-embed are gona fail. Wails can add dummy file to the dist
direcotry before first step. I think that this will fix issule.
Hi @wojtess , thanks for adding some info, but if I understand correctly the issue you're having is the one I'm describing in the reproduction steps step 13, and your workaround with the empty file is what I described in step 14.
This ticket is more about the error in step 15, because it's a more obscure error and I don't know where it comes from, and it doesn't happen in all Wails projects, just under certain circumstances.
But you're right in that the error from step 13 should also receive some attention and a proper fix, to not have to do the workaround with the temp file. Maybe you can open a separate issue?
I deleted frontend/dist
and still got the error (git cloned an existing wails project).
But adding a frontend/dist/gitkeep
file worked.
If you use embed, Go will fail to compile if it doesn't exist. The wails build process should compile your frontend assets and populate that directory so all should be good. If that fails for whatever reason, perhaps running build twice concurrently or some other process wiping it then the compilation will fail.
My problem was git clone
ing an existing wails project and running wails dev
or wails build
immediately.
Those commands did not work without manual intervention:
- Adding
frontend/dist/gitkeep
or anything else there so it's not empty or - Removing the
embed:
directive on the firstwails dev/build
run then adding it back