`tk env list` failures if there is a `main.jsonnet` file in the external library that also imports library
tk env list gives RUNTIME ERROR: couldn't open import ... if there is a main.jsonnet file in the external library installed using jb (i.e. in ./vendor/some-library-name) that imports other external library file.
To reproduce:
cd $(mktemp -d)
tk init -f --k8s 1.28
jb install github.com/pszulc1/trivial-lib-1@test-case-error
tk env list
Error: finding environments: Errors occurred during parallel processing:
- /tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa/main.jsonnet:
evaluating jsonnet in path '/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa/main.jsonnet': RUNTIME ERROR: couldn't open import "testonnet/main.libsonnet": no match locally or in the Jsonnet library paths
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa/main.jsonnet:1:14-47 thunk <test> from <$>
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa/main.jsonnet:3:1-5
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa:2:17-102 thunk <main> from <$>
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa:30:11-15 thunk from <$>
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa:6:21-27 thunk from <thunk from <function <noDataEnv>>>
<std>:31:26-27 thunk from <function <anonymous>>
<std>:31:17-28 function <anonymous>
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa:6:8-28 thunk from <function <noDataEnv>>
<std>:1613:20-21 thunk from <function <anonymous>>
<std>:32:25-26 thunk from <function <anonymous>>
<std>:32:16-27 function <anonymous>
<std>:1613:8-22 function <anonymous>
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa:(5:3)-(28:4) function <noDataEnv>
/tmp/tmp.u1AmiHytZ4/vendor/github.com/pszulc1/trivial-lib-1/aaa:30:1-16 $
During evaluation
The error relates to the ./vendor/trivial-lib-1/aaa/main.jsonnet file, which refers to a library that exists in the ./vendor folder.
There always seems to be a problem with tk if there is a vendor in the path to the main.jsonnet file that imports the library.
Renaming the main.jsonnet file bypasses the error.
I'm using tk version v0.27.1.
Hey π Sorry for the late response!
Very curious! So I basically had to rename trivial-lib-1/aaa/main.jsonnet to, for instance, trivial-lib-1/aaa/dummy.libsonnet for it to work.
$ mv vendor/trivial-lib-1/aaa/{main,dummy}.jsonnet
tk show environments/default does not complain since it does not do a full search for all files with the name main.jsonnet. I'm not completely sure if there is really a usecase for searching for such files also within the lib and vendor folders since main.jsonnet files should never be imported (that's what main.libsonnet files are there for).
So I see two issues here:
aaais importing amain.jsonnet- Tanka is looking in places for
main.jsonnetfiles that are usually not there to store environments
@iainlane @julienduchesne @Duologic What do you think? Should we exclude at least the vendor folder from the environment search?
Looking internally at where we run that command regularly I see that we limit it to the ./environments dir, so that's why we haven't hit that issue.
I'm not sure how much we can do, perhaps improve the error message? The directory layout is a convention and theoretically it could be that Tanka environments live in ./vendor π€·ββοΈ
I guess https://github.com/grafana/tanka/issues/957 is somewhat related?
@strowi Perhaps, although we also have main.jsonnet files in nested folders inside environments/ and don't seem to run into this issue π
We use Tanka as a Go library in internal tooling. The issue appeared after upgrading from v0.26.0 to v0.27.0 and persists in v0.36.0.
Weβre currently using the same workaround β placing main.jsonnet outside the directory that contains the vendor directory.