#ok, seems like using symbolic links also
1 messages · Page 1 of 1 (latest)
It's funny, while doing dev work on my trivy module, I created a peer level directory called test and init'ed a module there to drive/test trivy. As I change the trivy module, from the test/ directory I run dagger install ../trivy and it works fine.
~ ➤ tree -L 1 ~/src/daggerverse
/Users/jeremyadams/src/daggerverse/
├── LICENSE
...
├── test/
└── trivy/
yes, I think you can use some peer dirs as long as it's part of the same "project". Not sure if that's defined by your git repository or what
if you move your trivy project outside the daggerverse folder to some other path in your system I'd expect you'll get the same error I was getting
I'll try really quick...though I'm in the middle of trying to figure out how to get an exitcode from a WithExec() 😄
you need to use errors.As and cast it ExecError or something around that
you can only get it if the WithExec fails
yes, I saw all that. rather confusing. yeah, that last line makes sense.
I guess that's why someone might use a shell and save exit code in a file
test ➤ mv ../trivy /tmp
test ➤ dagger install /tmp/trivy
✘ moduleSource(refString: "/tmp/trivy"): ModuleSource! 0.0s
Error: failed to get module ref kind: input: resolve: moduleSource: local module source root path is absolute: /tmp/trivy
same error @white moth ?
yes. You should also get an error if you use relative paths as well
test ➤ mv /tmp/trivy ..
test ➤ dagger install ../trivy
test ➤
Yeah, it's fine when I move it back
if you do dagger install ../../../tmp/trivy it should also fail
test ➤ ls ../../../../../tmp/trivy
LICENSE dagger.gen.go go.mod main.go
README.md dagger.json go.sum querybuilder
test ➤ dagger install ../../../../../tmp/trivy
✘ ModuleSource.resolveFromCaller: ModuleSource! 0.0s
Error: failed to generate code: input: resolve: moduleSource: withDependencies: resolveFromCaller: failed to collect local module source deps: failed to collect local module source dep: missing config file /Users/jeremyadams/src/daggerverse/trivy/dagger.json
hmm not the same error I was getting
maybe your trivy.json file has some paths pointing to daggerverse?
test ➤ cat ../trivy/dagger.json git:main*
{
"name": "trivy",
"sdk": "go"
}
I haven't updated it with "source":
here's my test mod dagger.json:
test ➤ cat dagger.json git:main*
{
"name": "test",
"sdk": "go",
"dependencies": [
{
"name": "trivy",
"source": "../trivy"
}
],
"source": ".",
"engineVersion": "v0.9.10"
}
yeah strange.. I was getting this:
failed to collect local module source dep: local module dep source path
"../../home/marcos/Projects/daggerverse/dapr" escapes context "/tmp/quickstarts"
basically "escapes context". So seems like dagger has the concept of "context" while installing local modules by relative path. Not sure what's that about
what do the dagger.json file(s) look like?
{
"name": "dapr",
"sdk": "go",
"dependencies": [
{
"name": "go",
"source": "github.com/sagikazarmark/daggerverse/go@bc2ccb71307797d3066a56e1e57d75205523cfad"
}
]
}
that's the dep I'm trying to install
this is the module that I'm standing in
{
"name": "order-processor",
"sdk": "go",
"dependencies": [
{
"name": "go",
"source": "github.com/sagikazarmark/daggerverse/go@c9fc1a849646c47a86bdc71713c9760c69ce818a"
}
],
"source": "dagger",
"engineVersion": "v0.9.10"
}
I went to look at the dapr mods dependency...seems compatible ( // +optional etc, hmmm // +private pragma works?? cool )
Turns out the different sha for Mark's go mod you use in order-processor has exactly the same main.go...but the dagger.json files are different...just looking around
probably not a thing
@fast bobcat you weren't able to repro?
I think the error you got before when using relative paths is related to your local env
this error is weird.. why is it outputing daggerverse/trviy if you moved the module to /tmp?
yeah...very weird...
Just ran again. Different error
test ➤ cp -R ../trivy /tmp
test ➤ ls ../../../../../tmp/trivy
LICENSE dagger.gen.go go.mod main.go
README.md dagger.json go.sum querybuilder
test ➤ dagger install ../../../../../tmp/trivy
✘ ModuleSource.resolveFromCaller: ModuleSource! 0.0s
Error: failed to generate code: input: resolve: moduleSource: withDependencies: resolveFromCaller: failed to collect local module source deps: failed to collect local module source dep: local module dep source path "../../../../tmp/trivy" escapes context "/Users/jeremyadams/src/daggerverse"
this is the error that I get
ok, so can confirm it also happens to you 🙏
yes, I think you can use some peer dirs as long as it's part of the same "project". Not sure if that's defined by your git repository or what
Yes you can install a local dependency as long as it's under the same.gitrepo. The "context" is that git repo.
The reason for this is that if we didn't enforce this, you could push a module with a local dep to something outside the .git repo, but anyone trying to use it from that git remote would not be able to load it. Basically, any local path deps need to be self-contained within the git dir for consistent usability.
that makes sense. I guess that eventually we'll need a something similar to the replace directive from Go since otherwise iterating on local modules which are outside the project root path becomes quite a pain.
Yep that could definitely make sense. We would just need to prevent modules with that from being published.
Or we can allow publishing but then ignore the replace directive at install time like Go does
Coming into this thread from a search, cause I ran into this error today (the one where calling a sibling module results in "escapes context" error). I had no idea what "escapes context" meant as an end user and I had to read this thread to figure it out. Perhaps some simple text appended to the error explaining that locally referenced modules must be within the same git repository would be extremely helpful here
(it of course makes total sense why it is this way, but for an end user fixing their error they usually don't really care about the details, they just want to know to move their modules into the same git repository or at least be aware of the "limitation")
makes total sense connor. Will open an issue about it tomorrow if you don't beat me to it 😛. cc @glad jewel