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

Failing (pre|post)BuildHooks with no build/bin dir #2224

Closed
prochac opened this issue Dec 20, 2022 · 5 comments · Fixed by #2273
Closed

Failing (pre|post)BuildHooks with no build/bin dir #2224

prochac opened this issue Dec 20, 2022 · 5 comments · Fixed by #2273
Labels
Bug Something isn't working

Comments

@prochac
Copy link

prochac commented Dec 20, 2022

Description

If the build/bin directory is removed, or if the project is cloned, the wails dev fails on

ERROR: chdir /.../my-wails-project-dir/build/bin: no such file or directory - 

The build/bin dir is automatically added to .gitignore file, so the directory isn't being pushed to repository. That leads to that the dir is missing if the repo is cloned.

To Reproduce

wails init -n some-name
cd some-name
rm -r build
cat wails.json | jq '. + {"preBuildHooks": {"*/*": "echo"}}' | tee wails.json
# or
cat wails.json | jq '. + {"postBuildHooks": {"*/*": "echo"}}' | tee wails.json
wails dev

Expected behaviour

The wails cli could create the directory instead of failing

Screenshots

No response

Attempted Fixes

No response

System Details

Wails CLI v2.2.0

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

System
------
OS:             Arch Linux
Version:        Unknown
ID:             arch
Go Version:     go1.19.4
Platform:       linux
Architecture:   amd64

Wails
------
Version:                v2.2.0
Package Manager:        pacman

Dependency      Package Name    Status          Version
----------      ------------    ------          -------
*docker         docker          Installed       1:20.10.21-1
gcc             gcc             Installed       12.2.0-1
libgtk-3        gtk3            Installed       1:3.24.35-2
libwebkit       webkit2gtk      Installed       2.38.2-2
npm             npm             Installed       8.19.2-1
pkg-config      pkgconf         Installed       1.8.0-1

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!

Additional context

No response

@prochac prochac added the Bug Something isn't working label Dec 20, 2022
@stffabi
Copy link
Collaborator

stffabi commented Dec 21, 2022

Thanks for using Wails and reporting this issue.

Unfortunately I'm unable to reproduce this on macOS with Wails 2.2.0 by using your provided steps.

wails init -n some-name
cd some-name
rm -r build
wails dev

What version of Wails are you using? You mention something about BuildHooks in the title, but there's nothing mentioned in your repro guide.

@stffabi stffabi added the cannot reproduce The issue cannot be reproduced by the project maintainers label Dec 21, 2022
@leaanthony
Copy link
Member

Please provide system details as requested in the template. Thanks.

@prochac
Copy link
Author

prochac commented Dec 21, 2022

Oh, what a me 🤦
Of course, the hooks has to been added.
I have updated the reproduction scenario, could you retry pls

@lyimmi
Copy link
Contributor

lyimmi commented Dec 24, 2022

I can reproduce this with the provided steps on popOS 22.04.

It fails on /v2/pkg/commands/build/build.go#L413:

stdout, stderr, err := shell.RunCommand(options.BinDirectory, args[0], args[1:]...)

If I check and create the directory in /v2/pkg/commands/build/build.go#L88 it solves the problem.

// Set build directory
options.BinDirectory = filepath.Join(options.ProjectData.GetBuildDir(), "bin")
if !fs.DirExists(options.BinDirectory) {
  if err := fs.MkDirs(options.BinDirectory); err != nil {
    return "", fmt.Errorf("cannot build, target directory missing %w", err)
  }
}

Edit:
I forgot to mention, the missing build directory causes a problem only if wails.json has a build hook, otherwise everything is fine.

Used the current 2.2.0 wails cli, initially.

@stffabi stffabi removed the cannot reproduce The issue cannot be reproduced by the project maintainers label Dec 24, 2022
@lyimmi
Copy link
Contributor

lyimmi commented Jan 5, 2023

I'd like to fix this.

Is it ok if I check and or create the directory in /v2/pkg/commands/build/build.go:L407 before shell.RunCommand()

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

Successfully merging a pull request may close this issue.

4 participants