#ok, seems like using symbolic links also

1 messages · Page 1 of 1 (latest)

fast bobcat
#

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/
white moth
#

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

fast bobcat
#

I'll try really quick...though I'm in the middle of trying to figure out how to get an exitcode from a WithExec() 😄

white moth
#

you can only get it if the WithExec fails

fast bobcat
#

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 ?

white moth
fast bobcat
#
test ➤ mv /tmp/trivy ..                                                         
test ➤ dagger install ../trivy                                                  
test ➤

Yeah, it's fine when I move it back

white moth
fast bobcat
#
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
white moth
#

maybe your trivy.json file has some paths pointing to daggerverse?

fast bobcat
#
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"
}
white moth
#

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

fast bobcat
#

what do the dagger.json file(s) look like?

white moth
#
{
  "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"
}
fast bobcat
#

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

white moth
#

@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

white moth
fast bobcat
#

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"
white moth
#

ok, so can confirm it also happens to you 🙏

glad jewel
#

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 .git repo. 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.

white moth
glad jewel
white moth
remote dove
#

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")

white moth