gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 28 forks source link

gokr-packer fails when default instance (~/gokrazy/hello) exists #51

Closed damdo closed 3 weeks ago

damdo commented 1 year ago

When gokr-packer invokes the packing logic it also calls GenerateSBOM() here.

In turn within GenerateSBOM to set the buildDir we use the instancePath obtained via config.InstancePath().

Which for gokr-packer, where no instancePath is set, it falls back to ~/gokrazy/hello.

This in turn breaks gokr-packer if ~/gokrazy/hello exists:

2023/03/12 17:34:43 open /Users/ddonati/gokrazy/hello/builddir/github.com/gokrazy/gokrazy/go.mod: no such file or directory

To reproduce:

# create the default "hello" instance at the default gokrazy instance path
gok -i hello new

# then use gokr-packer to build/overwrite something to a full file.
stapelberg commented 1 year ago

Thanks for the report. The command only fails if ~/gokrazy/hello exists but has no builddir, but nevertheless we should fix it.

We use the “chdir-or-fallback” logic in a number of places, so we should update at least those code paths that the old gokr-packer can reach.