Hello! I’ve upgraded the dependencies of my proje...
# golang
b
Hello! I’ve upgraded the dependencies of my project and running
pulumi up
after that, I got the following error:
Copy code
# <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
    vendor/github.com/pjbgf/sha1cd/cgo/sha1.go:3:11: fatal error: lib/sha1.h: No such file or directory
        3 | // #include <lib/sha1.h>
          |           ^~~~~~~~~~~~
    compilation terminated.

    error: error in compiling Go: unable to run `go build`: exit status 2
The concerned package is an indirect dependency of the Go Pulumi SDK:
Copy code
❯ go mod why <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
# <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
<my-pulumi-go-project>
<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>
<http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin>
<http://github.com/pulumi/pulumi/sdk/v3/go/common/workspace|github.com/pulumi/pulumi/sdk/v3/go/common/workspace>
<http://github.com/go-git/go-git/v5/plumbing|github.com/go-git/go-git/v5/plumbing>
<http://github.com/go-git/go-git/v5/plumbing/hash|github.com/go-git/go-git/v5/plumbing/hash>
<http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
I did some search and I came across this pull request which should have solved the problem: https://github.com/pjbgf/sha1cd/pull/5. However, this is not the case because Pulumi doesn’t seem to build Go programs using
CGO_ENABLED=0
. What’s the reason why
CGO_ENABLED=0
is not used?
m
Hi Yann, Can you run
pulumi about
and maybe share your project (or parts of it, as possible)?
b
Sure, here is a sample project https://github.com/yann-soubeyrand/pulumi-cgo and `pulumi about`:
Copy code
CLI          
Version      3.48.0
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME  VERSION
go    unknown

Host     
OS       fedora
Version  37
Arch     x86_64

This project is written in go: executable='/usr/bin/go' version='go version go1.19.1 linux/amd64'

Current Stack: test

TYPE                 URN
pulumi:pulumi:Stack  urn:pulumi:test::cgo::pulumi:pulumi:Stack::cgo-test


Found no pending operations associated with test

Backend        
Name           toolbox
URL            file://.
User           yann
Organizations  

Pulumi locates its logs in /tmp by default
warning: Failed to get information about the Pulumi program's dependencies: failed to get modules: exit status 1
The root cause seems to be the vendoring: github.com/pjbgf/sha1cd/cgo includes C files in github.com/pjbgf/sha1cd/cgo/lib and vendoring of a package doesn’t include subfolders. However, using
export CGO_ENABLED=0
before running
pulumi up
makes it work.
The problem with github.com/pjbgf/sha1cd has been fixed. However, my question remains: is there a reason why Pulumi doesn't use
CGO_ENABLED=0
?
m
Hi Yann, best thing would be to open an issue in the Pulumi repo! The engineers can than engage with your suggestion better
b
Thanks for the suggestion @many-telephone-49025. I’ve open this discussion: https://github.com/pulumi/pulumi/discussions/11526