Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendoring with go mod vendor leads to "fatal error: 'config.h' file not found" #28

Closed
mattfenwick opened this issue Aug 10, 2020 · 5 comments · Fixed by #37
Closed

Vendoring with go mod vendor leads to "fatal error: 'config.h' file not found" #28

mattfenwick opened this issue Aug 10, 2020 · 5 comments · Fixed by #37

Comments

@mattfenwick
Copy link

mattfenwick commented Aug 10, 2020

Note: apologies if this issue has been reported before, or if there's a common solution to this problem -- it's the first time I've ever run into vendoring issues with a module including C source code so I'm still researching what's going on!

This could also be an issue with go mod vendor or my understanding of it.


I'm on Mac OS X 10.14.6.

When I vendor in graphviz using go mod vendor, I get a missing C header error:

# github.com/goccy/go-graphviz/internal/ccall
vendor/github.com/goccy/go-graphviz/internal/ccall/ccall.go:27:10: fatal error: 'config.h' file not found
#include "config.h"
         ^~~~~~~~~~
1 error generated.

I'm on graphviz 0.0.6:

✗ grep -i graphviz go.sum
github.com/goccy/go-graphviz v0.0.6 h1:sCT69fmH2KKsObVfsozYyKXxrqmIfo3SyHZs72xkgxs=
github.com/goccy/go-graphviz v0.0.6/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk=

Here's what gets vendored in -- none of the headers:

✗ tree vendor/github.com/goccy/go-graphviz/        
vendor/github.com/goccy/go-graphviz/
├── LICENSE
├── README.md
├── cdt
│   └── cdt.go
├── cgraph
│   ├── attribute.go
│   └── cgraph.go
├── go.mod
├── go.sum
├── graphviz.go
├── gvc
│   ├── gvc.go
│   ├── image_renderer.go
│   └── renderer.go
├── internal
│   └── ccall
│       ├── builtin.c
│       ├── ccall.go
│       ├── cdt.c
│       ├── cdt.go
│       ├── cgraph.c
│       ├── cgraph.go
│       ├── circogen.c
│       ├── common.c
│       ├── common.go
│       ├── dotgen.c
│       ├── expat.c
│       ├── expat.go
│       ├── fdpgen.c
│       ├── gvc.c
│       ├── gvc.go
│       ├── label.c
│       ├── neatogen.c
│       ├── ortho.c
│       ├── osage.c
│       ├── pack.c
│       ├── patchwork.c
│       ├── pathplan.c
│       ├── plugin.c
│       ├── rbtree.c
│       ├── sfdpgen.c
│       ├── sparse.c
│       ├── twopigen.c
│       └── xdot.c
└── option.go

When I just rm -r vendor, this problem goes away and everything works fine. (Unfortunately, I may be forced to vendor :( )

@dmitshur
Copy link

This is likely similar to go-gl/glfw#251. There needs to be at least one .go file in a directory for it to be considered a Go package and source files to be included by vendor.

@goccy
Copy link
Owner

goccy commented Aug 15, 2020

I am trying to solve this problem by writing the header content directly in the Go file ( cgo section ) .

@bogdanprodanj
Copy link

bogdanprodanj commented Aug 19, 2020

I've forked this repo and added dummy files so go mod vendor will include C files and it worked. I can create PR to fix this issue as a workaround for now

@yashbhutwala
Copy link

@bogdanprodanj do you have cycles to submit the PR?

@joelanford
Copy link
Contributor

I just submitted a #37, which seems to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants