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

tk env list failures if there is a main.jsonnet file in the external library that also imports library #1106

Open
pszulc1 opened this issue Jul 18, 2024 · 2 comments

Comments

@pszulc1
Copy link

pszulc1 commented Jul 18, 2024

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.

@zerok
Copy link
Contributor

zerok commented Nov 5, 2024

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:

  1. aaa is importing a main.jsonnet
  2. Tanka is looking in places for main.jsonnet files 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?

@zerok zerok moved this from Triage to In discussion in Tanka Nov 5, 2024
@Duologic
Copy link
Member

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 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In discussion
Development

No branches or pull requests

3 participants