This is the struccture of my project created with zig init-lib, thought might learn some basics by creating a library but some complications are arising.
Now in datetime.zig I want to import a helper function from helper1.zig (both helper1.zig files are same, I was just seeing which is working, both are not working)
when I do const random = @import("./helper1.zig"); in datetime.zig:
I get this error
error: unable to load 'src/utils/datetime/helper1.zig': FileNotFound
but when I do const random = @import("../../helper1.zig"); or const random = @import("../helper1.zig"); in datetime.zig:
I get this error
error: import of file outside package path: '../helper1.zig'
Again, searched google but the things Im seeing are not related, and do I really need to modify build.zig? since everything is in the src directory only, why are relative or absolute paths not working?
You had helpers missing in your import path. It should have been const random = @import("../../helpers/helper1.zig");, but you were using const random = @import("../../helper1.zig");, where the folder helpers, where your helper1.zig is located is missing in the import string.
@dude_the_builder provided you with some steps to follow that elucidate this further. I just wanted to show you where the error was. Sometimes, it is hard to catch. Specially if you are a beginner.
Take a second look. There is another helper1.zig down the tree.
I think he will need to provide the command used to build or run, I bet it has something to do with the root source dir. Alas this is a bit too late now, it has been a week since he posted