Repository navigation
Description
Originally reported in discord by @matipan and @marcosnils: https://discord.com/channels/707636530424053791/1003718839739105300/1273029522329178153
The below code does not work:
package main
import (
"dagger/foo/internal/dagger"
"fmt"
)
type Foo struct{}
func (m *Foo) Hello() *dagger.Container {
return dag.Container().
From("ubuntu").
WithWorkdir("/home/ubuntu").
WithExec([]string{"sh", "-c", "apt update && apt install -y git-core curl"}).
WithExec([]string{"sh", "-c", "curl -LO https://dl.dagger.io/dagger/install.sh && chmod +x install.sh"}).
WithExec([]string{"sh", "-c", fmt.Sprintf("DAGGER_VERSION=%s BIN_DIR=/usr/local/bin ./install.sh", "v0.16.3")}).
// this code does work
// WithExec([]string{"sh", "-c", "git clone https://github.com/shykes/daggerverse"}).
// WithWorkdir("/home/ubuntu/daggerverse/hello").
// WithExec([]string{"sh", "-c", "dagger call hello"}, dagger.ContainerWithExecOpts{ExperimentalPrivilegedNesting: true})
// this code does not work
WithExec([]string{"sh", "-c", "git clone https://github.com/shykes/daggerverse && cd daggerverse/hello && ls && cat dagger.json && dagger call hello"}, dagger.ContainerWithExecOpts{ExperimentalPrivilegedNesting: true})
}This gives us:
❯ dagger call hello
✔ connect 0.2s
✔ load module 0.7s
✔ parsing command line arguments 0.0s
✔ foo: Foo! 0.0s
✘ .hello: Container! 2.3s
! process "sh -c git clone https://github.com/shykes/daggerverse && cd daggerverse/hello && ls && cat dagger.json && dagger call hello" did not complete successfully: exit code: 1
│ ✔ container: Container! 0.0s
│ $ .from(address: "ubuntu"): Container! 0.4s CACHED
│ ✔ .withWorkdir(path: "/home/ubuntu"): Container! 0.0s
│ $ .withExec(args: ["sh", "-c", "apt update && apt install -y git-core curl"]): Container! 0.0s CACHED
│ $ .withExec(args: ["sh", "-c", "curl -LO https://dl.dagger.io/dagger/install.sh && chmod +x install.sh"]): Container! 0.0s CACHED
│ $ .withExec(args: ["sh", "-c", "DAGGER_VERSION=v0.16.3 BIN_DIR=/usr/local/bin ./install.sh"]): Container! 0.0s CACHED
│ ✘ .withExec(args: ["sh", "-c", "git clone https://github.com/shykes/daggerverse && cd daggerverse/hello && ls && cat dagger.json && dagger call hello"], experimentalPrivilegedNesting: true): Container! 1.4s
│ ┃ 1 : ! exit code 1
│ ┃
│ ┃ 5 : consuming /v1/traces
│ ┃ 5 : consuming /v1/traces DONE [0.0s]
│ ┃
│ ┃ 6 : consuming /v1/logs
│ ┃ 6 : consuming /v1/logs DONE [0.0s]
│ ┃
│ ┃ 7 : consuming /v1/metrics
│ ┃ 7 : consuming /v1/metrics DONE [0.0s]
│ ┃
│ ┃ 8 : moduleSource(refString: "."): ModuleSource!
│ ┃ 8 : moduleSource DONE [0.0s]
│ ┃
│ ┃ 9 : ModuleSource.configExists: Boolean!
│ ┃ 9 : ModuleSource.configExists DONE [0.0s]
│ ┃
│ ┃ 1 : hello ERROR [0.1s]
│ ┃ 1 : ! exit code 1
│ ┃ 1 : [0.1s] | Error: module not found
│ ┃
│ ┃ 9 : ModuleSource.configExists DONE [0.0s]
│ ┃ 9 : [0.0s] | false
│ ┃
│ ┃
│ ┃ Error: module not found
│ ! process "sh -c git clone https://github.com/shykes/daggerverse && cd daggerverse/hello && ls && cat dagger.json && dagger call hello" did not complete successfully: exit code: 1
│ │ ✘ hello 0.1s
│ │ ┃ Error: module not found
│ │ ! exit code 1
│ │ │ ✔ connect 0.0s
│ │ │ ✘ load module 0.1s
│ │ │ ! module not found
│ │ │ │ ✔ finding module configuration 0.1s
Something here is a little odd. I'm not quite sure why this error is given - potentially, it's reading the invalid top-level dagger.json.
@grouville suggested that the setupNestedClient is potentially the issue during initialization:
dagger/engine/buildkit/executor_spec.go
Lines 899 to 902 in ac342af
| filesyncer, err := client.NewFilesyncer( | |
| state.rootfsPath, | |
| strings.TrimPrefix(state.spec.Process.Cwd, "/"), | |
| &state.uid, &state.gid, |
Potentially this is the case, since I can adapt the above example into:
package main
import (
"dagger/foo/internal/dagger"
"fmt"
)
type Foo struct{}
func (m *Foo) Hello() *dagger.Container {
return dag.Container().
From("ubuntu").
WithWorkdir("/home/ubuntu").
WithExec([]string{"sh", "-c", "apt update && apt install -y git-core curl"}).
WithExec([]string{"sh", "-c", "curl -LO https://dl.dagger.io/dagger/install.sh && chmod +x install.sh"}).
WithExec([]string{"sh", "-c", fmt.Sprintf("DAGGER_VERSION=%s BIN_DIR=/usr/local/bin ./install.sh", "v0.16.3")}).
// this modified code does work!
WithWorkdir("/home/ubuntu/daggerverse/hello").
WithExec([]string{"sh", "-c", "cd /home/ubuntu && rm -r daggerverse && git clone https://github.com/shykes/daggerverse && cd daggerverse/hello && ls && cat dagger.json && dagger call hello"}, dagger.ContainerWithExecOpts{ExperimentalPrivilegedNesting: true})
}This then works. It seems possible that with the workdir is simply wrong when setting up the filesyncer in a way that is different from the way the client sees the filesystem.
cc @sipsma who worked on the filesyncer originally.
Activity
jedevc commentedon Mar 18, 2025
Tried this again optimistically, in the hope that recent module refactorings might have fixed it - sadly not 😢
Updated the above examples + errors to be their v0.16.3 equivalents.