You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Zenith: handle local module dependency being outside directory tree #5862
By setting the root to the directory above, we load the entire current directory, which lets that path lookup happen.
However, this is a bit confusing IMO - I would actually expect for local dependencies to be resolved relative to the root. On the other hand - it would be nice if we didn't have to set root at all and dependencies were just resolved relative to the directory of the module - but this would kind of violate the niceness of "just load a module from this directory".
I think we could load relative to the root quite simply by just modifying
@jedevc The idea of root is really just meant to handle the case where you have something like go.mod/package.json/etc. in a parent directory but your code can't run without it.
I think I'd prefer to keep its usage exclusively to that. Perhaps to the point where we should rename it to something hyper-specific like requiredParentLoadDir (don't like that name, just a strawman).
The reason being that it's inherently sort of confusing and not pleasant to work with and think about. It only exists out of necessity.
Along those lines, I think that resolving dependencies relative to root would deepen the confusion since now you have to mentally join together two separate paths to figure out where you're supposed to point to.
That being said, there is going to be something of an interaction between support for a dependency being out-of-tree an root, since root is currently how we decide what to load into the engine in the first place.
One possibility would be to look at the paths of dependencies and use those in combination with root to figure out what we need to load to get everything we'll need. The internal complexity would be sad since we'll still need to keep the behavior of "root" the same as today, but I suspect it would result in the most easy to understand behavior for end-users.
Let me know if any of this makes sense 😅I'm going through a lot issues right now so my attempts at explanation here is a bit rushed
That being said, there is going to be something of an interaction between support for a dependency being out-of-tree an root, since root is currently how we decide what to load into the engine in the first place.
Ok, so I dug into this as part of #6086. This just tries to hard-enforce how this works today, I actually think it's pretty reasonable with a bit more error prompting (why can't I load "../foo", oh it's not part of my root) and docs work.
One possibility would be to look at the paths of dependencies and use those in combination with root to figure out what we need to load to get everything we'll need. The internal complexity would be sad
Ahh, so my worry with this is that if we do this, users may attempt something like:
Obviously a bit exaggerated - but the issue here is that we'd end up loading the entire root directory (since that could be the only common directory between that module and ours). If a user wants that behavior, they should be required to put the target directory in the "root" field. Potentially we could do something here and create a "sparse" tree, and only include the contents of the requested modules (preserving the structure correctly).
Potentially we could do something here and create a "sparse" tree, and only include the contents of the requested modules (preserving the structure correctly).
Yes that's what I was imagining; we can do it with the right include/exclude opts I believe.
Honestly, the thought of how complicated that would get in our internal code makes me inclined to wait for users actually request this rather than jump right into it. But I do suspect it will come up in monorepo-type use cases where one module may want a dep on another that lives in a totally different part of the tree, but they also don't want to load the entire "root" either.
Honestly, the thought of how complicated that would get in our internal code makes me inclined to wait for users actually request this rather than jump right into it.
Massive +1 on this, I think #6086 gets us close enough for now, we can park this until someone asks for it 🎉
Activity
jedevc commentedon Oct 11, 2023
Ok, so actually you kinda can do this already, just in a fairly confusing way:
Imagine a current directory with a
fooandbarmodule. If we wantbarto importfoo, we can:{ "name": "bar", "sdk": "go", "sdkRuntime": "vito/dagger-sdk-go:no-ptrs@sha256:2bb26bae3f30b920a4530b7495127fe4986102b06a99ff170500e83c25739b27", "root": "..", "dependencies": [ "../foo" ] }By setting the
rootto the directory above, we load the entire current directory, which lets that path lookup happen.However, this is a bit confusing IMO - I would actually expect for local dependencies to be resolved relative to the
root. On the other hand - it would be nice if we didn't have to set root at all and dependencies were just resolved relative to the directory of the module - but this would kind of violate the niceness of "just load a module from this directory".I think we could load relative to the root quite simply by just modifying
dagger/core/module.go
Line 169 in af58e2a
This could just be updated to resolve entirely relative to the root.
sipsma commentedon Oct 14, 2023
@jedevc The idea of root is really just meant to handle the case where you have something like
go.mod/package.json/etc. in a parent directory but your code can't run without it.I think I'd prefer to keep its usage exclusively to that. Perhaps to the point where we should rename it to something hyper-specific like
requiredParentLoadDir(don't like that name, just a strawman).The reason being that it's inherently sort of confusing and not pleasant to work with and think about. It only exists out of necessity.
Along those lines, I think that resolving dependencies relative to root would deepen the confusion since now you have to mentally join together two separate paths to figure out where you're supposed to point to.
That being said, there is going to be something of an interaction between support for a dependency being out-of-tree an root, since root is currently how we decide what to load into the engine in the first place.
One possibility would be to look at the paths of dependencies and use those in combination with root to figure out what we need to load to get everything we'll need. The internal complexity would be sad since we'll still need to keep the behavior of "root" the same as today, but I suspect it would result in the most easy to understand behavior for end-users.
Let me know if any of this makes sense 😅I'm going through a lot issues right now so my attempts at explanation here is a bit rushed
jedevc commentedon Nov 7, 2023
Ok, so I dug into this as part of #6086. This just tries to hard-enforce how this works today, I actually think it's pretty reasonable with a bit more error prompting (why can't I load "../foo", oh it's not part of my root) and docs work.
Ahh, so my worry with this is that if we do this, users may attempt something like:
{ ... "dependencies": [ "../../../../home/otheruser/modules" ] }Obviously a bit exaggerated - but the issue here is that we'd end up loading the entire root directory (since that could be the only common directory between that module and ours). If a user wants that behavior, they should be required to put the target directory in the "root" field. Potentially we could do something here and create a "sparse" tree, and only include the contents of the requested modules (preserving the structure correctly).
sipsma commentedon Nov 13, 2023
Yes that's what I was imagining; we can do it with the right
include/excludeopts I believe.Honestly, the thought of how complicated that would get in our internal code makes me inclined to wait for users actually request this rather than jump right into it. But I do suspect it will come up in monorepo-type use cases where one module may want a dep on another that lives in a totally different part of the tree, but they also don't want to load the entire "root" either.
jedevc commentedon Nov 14, 2023
Massive +1 on this, I think #6086 gets us close enough for now, we can park this until someone asks for it 🎉
sipsma commentedon Feb 21, 2024
This was done in #6575