#dagger.json issues

1 messages ยท Page 1 of 1 (latest)

untold vortex
#

What happens when you try that command?

mortal fjord
#

oops sorry i pasted in the main chat

#

let me move it

untold vortex
#

@mortal fjord seeing this error:

Error: load package ".": package name is empty

Do these subdirectories exist? daggerverse/java, daggerverse/docker, daggerverse/oauth?

mortal fjord
#
Error: failed to generate code: input: resolve: moduleSource: withName: withSDK: withSourceSubpath: resolveFromCaller: asModule: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name sonar --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1

Stderr:
Error: load package ".": package name is empty
untold vortex
#

Are you able to paste the output of find . or equivalent?

mortal fjord
untold vortex
#

can you run dagger functions from the root module?

mortal fjord
#

This is find . from daggerverse dir

.
./docker
./docker/go.mod
./docker/querybuilder
./docker/querybuilder/marshal.go
./docker/querybuilder/querybuilder.go
./docker/dagger.gen.go
./docker/go.sum
./docker/.gitignore
./docker/dagger.json
./docker/.gitattributes
./docker/main.go
./oauth
./oauth/go.mod
./oauth/querybuilder
./oauth/querybuilder/marshal.go
./oauth/querybuilder/querybuilder.go
./oauth/dagger.gen.go
./oauth/go.sum
./oauth/.gitignore
./oauth/dagger.json
./oauth/.gitattributes
./oauth/main.go
./java
./java/go.mod
./java/querybuilder
./java/querybuilder/marshal.go
./java/querybuilder/querybuilder.go
./java/dagger.gen.go
./java/resources
./java/resources/settings.xml
./java/go.sum
./java/.gitignore
./java/dagger.json
./java/.gitattributes
./java/main.go
./sonar
./.gitattributes
untold vortex
#

That will tell us if the module is currently in a good state

#

OK, so at the moment there is no root module (no dagger.json at the root)

mortal fjord
untold vortex
#

ah I see

mortal fjord
untold vortex
#

ok ๐Ÿ™‚

mortal fjord
#

output of dagger functions from root (after setting back dagger.json)

Error: input: resolve: moduleSource: resolveFromCaller: asModule: initialize: module name and SDK must be set

untold vortex
#

What's the output of dagger version?

mortal fjord
untold vortex
#

are you able to share the contents of that dagger.json?

mortal fjord
#

I did, let me repaste, I am redacting the name of the module but here it is

{
  "name": "mymodule",
  "dependencies": [
    {
      "name": "docker",
      "source": "daggerverse/docker"
    },
    {
      "name": "java",
      "source": "daggerverse/java"
    },
    {
      "name": "oauth",
      "source": "daggerverse/oauth"
    }
  ],
  "engineVersion": "v0.9.9"
}
#

here's the contents of daggervers/docker/dagger.json

{
  "name": "docker",
  "sdk": "go",
  "source": ".",
  "engineVersion": "v0.9.9"
}
#

hmm, if I create a new folder in my home directory called daggertest/sonar and run dagger init --sdk=go --name=sonar it works.

untold vortex
#

total brainfart on my side

mortal fjord
#

no worries!

untold vortex
#

So, it actually makes sense that dagger functions doesn't return anything useful, since your root module doesn't have any functions of its own. Obviously we need to add more polish, that error is too rough, but it's probably not what's blocking you.

#

@mortal fjord what are you trying to do where you are stuck?

mortal fjord
#

right

untold vortex
#

For example this should work: dagger -m ./daggerverse/docker functions

#

And ideally, this should also work since you installed it as a dependency: dagger -m docker functions. Although @strong summit has been having issues getting that to work

mortal fjord
#

So basically I am trying to build my own daggerverse. It was working fine pre-0.9.9. What I tried to do with the root is make it a module so I can call them via dagger -m docker ... etc.

untold vortex
#

Ah I see. Well to make your own daggerverse, you don't need a root dagger.json at all. As long as your individual modules load correctly, you shouldn't need to change anything.

mortal fjord
#

I don't care too much about the root. I can live without it. But the biggest problem now is dagger engine has gotten into some bad state. i can't even initialize individual modules within my daggerverse folder

untold vortex
#

My own daggerverse repo hasn't changed in that regard in months. The only thing I need to fix at the moment, is how my individual modules handle optional arguments in Go. Other than that, no breaking change.

mortal fjord
#

my individual modules had root specified. So when 0.9.9 came along I went into each module and did a dagger develop which restructured the dagger.json and removed root

untold vortex
mortal fjord
#

That was the idea yes. but based on recent changes to dagger I resorted to passing whatever needed via CLI args

untold vortex
#

I tried this in my daggerverse:

$ dagger version
dagger v0.9.9 (registry.dagger.io/engine) darwin/arm64
$ dagger init --sdk go ./sonar
WARNING: no LICENSE file found; generating one for you, feel free to change or remove license="Apache-2.0"

Initialized module sonar in ./sonar
$ cat dagger.json
cat: dagger.json: No such file or directory
$ cat sonar/dagger.json
{
  "name": "sonar",
  "sdk": "go",
  "source": "dagger",
  "engineVersion": "v0.9.9"
}
$
mortal fjord
#

yes I see the same if I dagger init outside of this project..

untold vortex
#

(Don't love the default dagger/ in that context, but that's a separate design conversation with its own tradeoffs...)

mortal fjord
#

yeah same

#

my default is .

#
 cat daggerverse/java/dagger.json
{
  "name": "java",
  "sdk": "go",
  "dependencies": [
    {
      "name": "docker",
      "source": "../docker"
    }
  ],
  "source": ".",
  "engineVersion": "v0.9.9"
}
visual perch
# mortal fjord yeah same

Hello Nipuna, jumping in also. Did you manage to repro on the side apart your current daggerverse ?

From what I understand, you have a root module as such:

{
  "name": "mymodule",
  "dependencies": [
    {
      "name": "docker",
      "source": "daggerverse/docker"
    },
    {
      "name": "java",
      "source": "daggerverse/java"
    },
    {
      "name": "oauth",
      "source": "daggerverse/oauth"
    }
  ],
  "engineVersion": "v0.9.9"
}

So a tree like this:

daggerverse
 /docker
 /java
 /oauth

Now, each of these modules work with 0.9.9 when calling them from the root, and each of them have the engineVersion set as v0.9.9

dagger call -m ./docker
dagger call -m ./oauth
dagger call -m ./java
  • Now, the docker have such dagger.json:
{
  "name": "docker",
  "sdk": "go",
  "source": ".",
  "engineVersion": "v0.9.9"
}
  • The java has:
{
  "name": "java",
  "sdk": "go",
  "dependencies": [
    {
      "name": "docker",
      "source": "../docker"
    }
  ],
  "source": ".",
  "engineVersion": "v0.9.9"
}
``` and references the docker

What about the oauth, is it referencing any of these modules ?

To summarize, whenever you do a `dagger init newmodule`, in that configuration it breaks ?
mortal fjord
#

the oauth module does not have deps. but there's another one in there that depends on another mod

visual perch
#

so oauth is like this:

{
  "name": "oauth",
  "sdk": "go",
  "source": ".",
  "engineVersion": "v0.9.9"
}
mortal fjord
#

yes exactly

#

Heres the other module with deps

{
  "name": "(redacted)",
  "sdk": "go",
  "dependencies": [
    {
      "name": "docker",
      "source": "../docker"
    },
    {
      "name": "java",
      "source": "../java"
    }
  ],
  "source": ".",
  "engineVersion": "v0.9.9"
}
#

It all looks very vanilla. Hence why i'm stumped this is not working

visual perch
#

hmm, so two modules are depended on docker, one with some depth. Ok, trying a repro from scratch on the side ๐Ÿ‘€

mortal fjord
#

hmm, i cannot repro it in a new folder.. so strange

#

same structure

#

same modules

visual perch
#

looks a lot like a state issue then. Did you try to kill the engine, remove its cache ?

mortal fjord
#

by removing cache you mean remove the local volume? Is there anything else I need to clear?

mortal fjord
#

tried that, didn't make a difference ๐Ÿ˜ฆ

#

I wonder if my existing project being a go project has something to do with it. That's the only difference between my repro attempt and original

visual perch
mortal fjord
#

interestingly dagger init --sdk=python --name=newmodule worked.. So something to do with Go.

visual perch
mortal fjord
#

I get the error regardless of the name of the module

visual perch
#

In the codebase, the issue is as such:

case 1:
        if pkgs[0].Name == "" {
            // this happens when loading an empty dir within an existing Go module
            return nil, nil, fmt.Errorf("package name is empty")
        }
        return pkgs[0], fset, nil
mortal fjord
#

I think dagger install. I stepped out for a bit will check when I get back. Really appreciate you looking into this!

verbal marlin
#

this looks specific to the Go SDK, as opposed to all the SDKs - what's weird to me is why this ever worked, this specific code path is quite old (like when we started zenith)

mortal fjord
#

Sorry I am back to testing this. @verbal marlin I didn't get what you meant. My root dir is an existing Go project are you saying that's a conflict somehow?

verbal marlin
#

yeah it looks like it - thankfully, i managed to reproduce this!

#

i'll open an issue

#

i left a suggested workaround, i'll try and come back and address this later - i'm a bit caught up today with an internal hackathon โค๏ธ

mortal fjord
#

awesome! I can do the workaround for now as it only fails on new module creation. I won't have to do that many times.

#

Yes! That worked. Seems like folks developing CI modules for Go apps will run into this fairly often.

verbal marlin
#

wow lol, it really is ridiculously easy to hit this everywhere isn't it ๐Ÿ˜„
can't believe it was such a pain to find it ๐Ÿ˜›

mortal fjord
#

haha. I was the first unlucky soul to hit it I guess. Glad you figured it out though!

untold vortex
#

Thank you for tracking this down guys, and for your patience Nipuna

verbal marlin
#

If you're comfortable testing against a dev engine, I'm curious if this resolves your issue

#

I think the issue is with parent go.works causing issues, but potentially there could be multiple things here

#

(also bleh, those couple of lines with the actual fix, if you average them out, i guess it's a nice average code-writing speed of 2 lines an hour ๐Ÿ˜ข)

mortal fjord
#

Woot!! I haven't done a lot of testing with the dev engine. I know at some point there was a engine module. Is there an updated document on how to test with the dev engine?

mortal fjord
#

easy enough, let me try that

#

bleh, didn't work. ./hack/dev failed because the internal Go image does not have my company CA certs. So it fails to go mod download ๐Ÿ˜ฆ

mortal fjord
#

I've been trying to use the workaround for this but I can't do much. When I rename the go.mod and go.work files, my autocompletion breaks. dagger develop seems to work but then it actually generates the code for the example module and not the one I have coded. When I name go.mod and go.work back, dagger develop fails with the same error I saw originally. So I am effectively stuck

verbal marlin
#

hm, can you make sure that the go.work includes the go.mod defined by your dagger module

#

this is essentially what my fix does - makes sure it's included if you're using a go.work

mortal fjord
#

yeah my go work has the new module. Let me double check

verbal marlin
#

hmmm if your go.work has the dagger module included, and you're still getting the issue, then there's something else going on

mortal fjord
#
go 1.21.3

toolchain go1.21.5

use (
        .
        ./daggerverse/docker
        ./daggerverse/java
        ./daggerverse/lwc
        ./daggerverse/oauth
        ./daggerverse/sonar
)

./daggerverse/sonar is the module I am trying to build

verbal marlin
#

and dagger develop in the sonar directory gives the package name is empty error?

mortal fjord
#

yes.. just checked again

#

what's weird is, it doesn't error out in my other modules

verbal marlin
#

hm, what's ls -lha ./daggerverse/sonar give?

mortal fjord
#

I cropped where it shows my user

verbal marlin
#

are there significant differences between that and the other dirs?

mortal fjord
#

hmm.. other modules have a .gitignore but not the dagger folder. I thought i moved everything out of the dagger folder the other day

#

so that dagger folder also has a go.mod. I wonder if that's causing the issue

#

removing the dagger folder didn't change anything FWIW

verbal marlin
#

oh, did you also update the source value in the dagger.json for that module

#

if you removed the dagger folder

mortal fjord
#

oh I did not

#

let me update it

#

ok changing the source fixed it.

#

That error message could be better

verbal marlin
#

yeah, i'm not actually sure how you got it though

mortal fjord
#

So I guess the issue was, the dagger folder was not in go.work

verbal marlin
#

ohhhh

#

yes

mortal fjord
#

it was the top level ./daggerverse/sonar folder that was in go.work