Closed sfc-gh-ptabor closed 1 year ago
@sfc-gh-ptabor can you define "working outside of directory"? What use case did you do that triggered a problem?
I would guess that this is a bug that's been around forever...
We try to Getwd
here:
https://github.com/chainguard-dev/apko/blob/c68c72f556a384fa805c0ced7eb9cb823b63edee/internal/cli/commands.go#L28-L32
And then change to that dir here:
But that just totally ignores the --workdir
flag.
At least for my usage, I tend to invoke apko
in a directory with a bunch of apko configs rather than in a directory where I want to populate a filesystem... I don't think we can "fix" this to use the current directory as the workdir because it would break so many existing things, but we could have the default value be a temporary directory (as it currently is now) and have the --workdir
flag let you set a specific directory.
Is that the behavior you'd expect?
Or do you want to os.Chdir
to the --workdir
before invoking apko
, but still build to a temporary directory?
I usually do as well, but sometimes you need to reference other dirs, especially in debug mode. Either way, it should work if it is there. Fixed in #830.
I spotted that 'apko build' is working outside of directory given using
--workdir
flag.I suspect this piece of code: https://github.com/chainguard-dev/apko/blame/1e5f9dbfd40406c0219c30ffa9ee34007814a438/internal/cli/build.go#L146
is Ignoring https://github.com/chainguard-dev/apko/blame/1e5f9dbfd40406c0219c30ffa9ee34007814a438/internal/cli/commands.go#L55C2-L55C2: