chainguard-dev / rules_apko

Bazel rules for apko
https://apko.dev
Apache License 2.0
25 stars 16 forks source link

error generating lock file from scratch #68

Open punsoong-canva opened 6 months ago

punsoong-canva commented 6 months ago

👋. Following the README to generate a lock for the first time (or if the lock file is deleted) errors when using the bazel run commands.

➜  rules_apko git:(main) ✗ bazel run @rules_apko//apko lock examples/wolfi-base/apko.yaml
ERROR: Traceback (most recent call last):
        File "/Users/punsoong/work/rules_apko/apko/extensions.bzl", line 37, column 56, in _apko_extension_impl
                lock_file = util.parse_lock(module_ctx.read(lock.lock))
Error in read: Not a regular file: /Users/punsoong/work/rules_apko/examples/wolfi-base/apko.lock.json
ERROR: Analysis of target '//apko:apko' failed; build aborted: error evaluating module extension apko in //apko:extensions.bzl
INFO: Elapsed time: 0.077s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
ERROR: Build failed. Not running target

I can work around this by manually generating a new lock file with apko lock examples/wolfi-base/apko.yaml --output examples/wolfi-base/apko.lock.json, then subsequent bazel run @rules_apko//lock <path_to>/apko.yaml commands will update the lock file.

sfc-gh-mhazy commented 5 months ago

I think this is because you might have declared translate_apko_lock before generating the lock for the first time (and it referenced the not yet existing lockfile)