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
🐞 Parent directory is uploaded when working in a module subdir #8395
I'm running the command in dagger/foo. That makes me think that the context directory is foo. There is no reason for it to go up a level - there is no configuration in the default init module that would make it behave this way.
A module has 3 directories (ignore the new "context directories" feature as that's something different):
context directory: git root (where .git is) or the root directory if not in a git repo
root directory: the directory where dagger.json is
source directory: the directory referenced in "source" in dagger.json
So in effect, if you're in the root of the dagger/dagger repo and dagger init --sdk=go foo, that'll load all the Go code in the repo along with that foo module. Even in other sibling directories.
Note that this depends on what you have locally. For example I have sdk/php/vendor and that's the biggest contributor. If you have other modules in the repo with generated code, that should be loaded as well.
I think this is a somewhat known issue? dagger init uploads parent directories - up to the root, this was so it could detect parent go.mods and similar. I'm sure we've discussed this before (I seem to remember with @jpadams, there was a conversation around daggerizing existing repos with this), but I cannot find a corresponding issue for it.
It's not fully necessary to do this in most cases, and we could probably do much better with the context dir primitives we now have.
For running a module, I'm not sure. Can you share the module that's in the subdir that you're hitting the issue with?
It's working by design because we wanted to support in-depth integration with an existing project, but we’re now converging on getting consensus to sandbox by default. See:
Today, when a module is loaded within a repo, the upload starts from the repo root. Let's put your module example deeper in the tree: foo/bar. The engine, by default, adds these include patterns:
# includes from your dagger.json, prefixed with `foo/bar/`foo/bar/dagger.jsonfoo/bar/**/*
The engine will apply those includes first, and then these excludes:
.git/**# excludes from your dagger.json, prefixed with `foo/bar/`
However, the Go SDK adds a few more includes for Go modules:
@sipsma I think with the refactorings to the module loading system these issues should be resolved now right? We should only be uploading the files needed for the module.
Activity
helderco commentedon Sep 10, 2024
Uhh.. this explains a lot actually!
helderco commentedon Sep 10, 2024
Wait, taking a closer look. It seems that it's loading the context directory, not necessarily the parent directory right? That's expected.
gerhard commentedon Sep 10, 2024
I'm running the command in
dagger/foo. That makes me think that the context directory isfoo. There is no reason for it to go up a level - there is no configuration in the default init module that would make it behave this way.Did you try to follow the steps to reproduce?
helderco commentedon Sep 10, 2024
A module has 3 directories (ignore the new "context directories" feature as that's something different):
.gitis) or the root directory if not in a git repodagger.jsonis"source"indagger.jsonSo in effect, if you're in the root of the dagger/dagger repo and
dagger init --sdk=go foo, that'll load all the Go code in the repo along with thatfoomodule. Even in other sibling directories.helderco commentedon Sep 10, 2024
I followed your steps to reproduce and this is what I see that is being uploaded in
resolveFromCaller: https://app.warp.dev/block/8wnHMlOFRKJWTysCpr696NNotice the size: 4493546. It's ≈40MiB, but perhaps it's the sheer quantity of files that's at fault more than the size (5448 items).
helderco commentedon Sep 10, 2024
Note that this depends on what you have locally. For example I have
sdk/php/vendorand that's the biggest contributor. If you have other modules in the repo with generated code, that should be loaded as well.helderco commentedon Sep 10, 2024
On a clean clone I get ≈6MiB of disk usage, with 899 items: https://app.warp.dev/block/qGFfHgWkKDEcH7Ty04833F
gerhard commentedon Sep 12, 2024
Why is the directory where
.gitis getting uploaded?This is the unexpected part for me, even though it seems that it's working as expected.
helderco commentedon Sep 12, 2024
I don't think
.gitis being uploaded (as it's excluded by default), it's the directory where.gitis, i.e., the repo root.gerhard commentedon Sep 12, 2024
Yes: why is the context directory (where
.gitis) getting uploaded?jedevc commentedon Sep 12, 2024
I think this is a somewhat known issue?
dagger inituploads parent directories - up to the root, this was so it could detect parentgo.mods and similar. I'm sure we've discussed this before (I seem to remember with @jpadams, there was a conversation around daggerizing existing repos with this), but I cannot find a corresponding issue for it.It's not fully necessary to do this in most cases, and we could probably do much better with the context dir primitives we now have.
For running a module, I'm not sure. Can you share the module that's in the subdir that you're hitting the issue with?
gerhard commentedon Sep 12, 2024
Yes, this definitely doesn't seem right.
The module is:
dagger init --sdk=go --name=foo -vvvhelderco commentedon Sep 20, 2024
It's working by design because we wanted to support in-depth integration with an existing project, but we’re now converging on getting consensus to sandbox by default. See:
Today, when a module is loaded within a repo, the upload starts from the repo root. Let's put your module example deeper in the tree:
foo/bar. The engine, by default, adds these include patterns:The engine will apply those includes first, and then these excludes:
However, the Go SDK adds a few more includes for Go modules:
dagger/core/schema/sdk.go
Lines 485 to 498 in fa9d3c7
So if you have a Go module, these are the include patterns you end up with:
I created the following issue to stop doing this by default:
jedevc commentedon Apr 11, 2025
@sipsma I think with the refactorings to the module loading system these issues should be resolved now right? We should only be uploading the files needed for the module.