Discussion on: @import() and Packages

jumpnbrownweasel profile image

Thanks for this! It is the only thing I could find in doc or by googling about relative imports.

However, a gotcha is that "zig test " doesn't use build.zig and assumes the root is the directory containing the test file, so imports outside of that directory aren't allowed:


The solution is to pass "--main-pkg-path " to "zig test" as mentioned above.

This was super confusing and took a while to figure out, so I think it would be really helpful if you wouldn't mind adding something about it to the article for future searchers.