#Error with exporting

1 messages ยท Page 1 of 1 (latest)

hazy vault
#

Hello, i have an error with the demo with the Golang SDK
I have exactly copied the following example : https://docs.dagger.io/sdk/go/959738/get-started#step-4-create-a-single-build-pipeline and i ended up finishing with an error on the output. Export(ctx, path)

The code :

func daggerBuild() error {
    ctx := context.Background()

    client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout))
    if err != nil {
        fmt.Printf("Error connecting to Dagger Engine: %s\n", err)
        os.Exit(1)
    }
    defer client.Close()

    src := client.Host().Directory(".")

    golang := client.Container().From("golang:latest")
    golang = golang.WithMountedDirectory("/src", src).WithWorkdir("/src")

    path := "build/"
    golang = golang.WithExec([]string{"go", "build", "-o", path})

    output := golang.Directory(path)
    _, err = output.Export(ctx, path)
    if err != nil {
        fmt.Printf("Error on export: %s", err)
    }

    return nil
}

The error :

#1 resolve image config for docker.io/library/golang:latest
#1 DONE 1.3s

#2 mkdir /meta
#2 DONE 0.0s

#3 local://C:\Users\xxx\GolandProjects\FilesManagement
#3 transferring C:\Users\xxx\GolandProjects\FilesManagement: 7.93kB 0.0s done
#3 DONE 0.0s

#4 docker-image://docker.io/library/golang:latest
#4 resolve docker.io/library/golang:latest
Error on exporting: input:1: container.from.withMountedDirectory.withWorkdir.withExec.directory.export destination "C:\\Users\\xxx\\GolandProjects\\FilesManagement\\build" escapes workdir

Did someone know how to solve this ? Thank you !
PS: Sorry if my English is bad by the way ^^

hazy vault
fringe fern
#

From what I see, I believe that the dir from which you run your script is C:\\Users\\xxx\\GolandProjects\\FilesManagement ?

Does the C:\\Users\\xxx\\GolandProjects\\FilesManagement\\build dir exist ?

#

The error says that you are exporting to somewhere that doesn't belong to your workdir: for security purposes, we only able to export to the context on which the run applies.

I believe it's either:

  1. It's truly the case (or we might need for build to exist ?)
  2. We have an issue with windows backslashes
#

Keep us in touch ๐Ÿ™

hazy vault
#

Ok i will check when i'll be back home. Thanks again!

fringe fern
hazy vault
fringe fern
hazy vault
#

here you go

hazy vault
#

any news ?

fringe fern
# hazy vault any news ?

Hi,
I'm currently debugging it. We indeed have a bug, currently testing my fix. Will keep you in touch here + on PR

hazy vault
fringe fern
#

You'll have to use the dev version of Dagger until the next release, but it will unlock you

#

Your fix has been merged ! Do not hesitate to ping if you have issues running the dev version of Dagger