could not determine kind of name for C.git_buf_dispose #617

Closed
opened 2020-06-19 23:59:54 -05:00 by xiaoxinda · 4 comments
xiaoxinda commented 2020-06-19 23:59:54 -05:00 (Migrated from github.com)

error is :
./../pkg/mod/github.com/libgit2/git2go/v29@v29.0.2/branch.go:211:8: could not determine kind of name for C.git_buf_dispose

centos:
my libgit2 is :0.99.0

pkg-config --modversion libgit2

0.99.0

[root@b2041d067d45 gitProxy]# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/go/src/gitProxy/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build524585300=/tmp/go-build -gno-record-gcc-switches"

error is : ./../pkg/mod/github.com/libgit2/git2go/v29@v29.0.2/branch.go:211:8: could not determine kind of name for C.git_buf_dispose centos: my libgit2 is :0.99.0 # pkg-config --modversion libgit2 # 0.99.0 [root@b2041d067d45 gitProxy]# go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/go" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/root/go/src/gitProxy/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build524585300=/tmp/go-build -gno-record-gcc-switches"
lhchavez commented 2020-06-20 08:33:11 -05:00 (Migrated from github.com)

hmm I'm unable to reproduce this :S

cat > Dockerfile <<EOF
FROM centos:latest

RUN yum -y groupinstall "Development Tools"
RUN yum -y install cmake openssl-devel
RUN curl --location https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz | \
    tar xz -C /usr/local
RUN curl --location https://github.com/libgit2/libgit2/releases/download/v0.99.0/libgit2-0.99.0.tar.gz | \
    tar xz -C ~
RUN mkdir -p ~/libgit2-0.99.0/build
RUN (cd ~/libgit2-0.99.0/build && \
     cmake \
         -DBUILD_CLAR=OFF \
         -DUSE_SSH=OFF \
         -DCMAKE_INSTALL_PREFIX=/usr \
         -DLIB_INSTALL_DIR=/usr/lib64 \
         -DPKG_BUILD_LIBDIR=lib64 \
         .. && \
     cmake --build . --target install)

ENV PATH=$PATH:/usr/local/go/bin
RUN mkdir -p ~/go
WORKDIR ~/go
RUN go mod init example.com/m
RUN go get github.com/libgit2/git2go/v29
RUN go test github.com/libgit2/git2go/v29/...
EOF
docker build .
Step 1/13 : FROM centos:latest
 ---> 831691599b88
...
Step 11/12 : RUN go mod init example.com/m
 ---> Running in 2099c98770e8
go: creating new go.mod: module example.com/m
Removing intermediate container 2099c98770e8
 ---> 7d959c515827
Step 12/12 : RUN go get github.com/libgit2/git2go/v29
 ---> Running in fcf0b2af3708
go: downloading github.com/libgit2/git2go v0.28.4
go: downloading github.com/libgit2/git2go/v29 v29.0.2
go: github.com/libgit2/git2go/v29 upgrade => v29.0.2
Removing intermediate container fcf0b2af3708
 ---> 990871f39996
Step 13/13 : RUN go test github.com/libgit2/git2go/v29/...
 ---> Running in ca9cf6bc3144
ok      github.com/libgit2/git2go/v29   0.476s
Removing intermediate container ca9cf6bc3144
 ---> 82e3cb56e9da
Successfully built 82e3cb56e9da
hmm I'm unable to reproduce this :S ```shell cat > Dockerfile <<EOF FROM centos:latest RUN yum -y groupinstall "Development Tools" RUN yum -y install cmake openssl-devel RUN curl --location https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz | \ tar xz -C /usr/local RUN curl --location https://github.com/libgit2/libgit2/releases/download/v0.99.0/libgit2-0.99.0.tar.gz | \ tar xz -C ~ RUN mkdir -p ~/libgit2-0.99.0/build RUN (cd ~/libgit2-0.99.0/build && \ cmake \ -DBUILD_CLAR=OFF \ -DUSE_SSH=OFF \ -DCMAKE_INSTALL_PREFIX=/usr \ -DLIB_INSTALL_DIR=/usr/lib64 \ -DPKG_BUILD_LIBDIR=lib64 \ .. && \ cmake --build . --target install) ENV PATH=$PATH:/usr/local/go/bin RUN mkdir -p ~/go WORKDIR ~/go RUN go mod init example.com/m RUN go get github.com/libgit2/git2go/v29 RUN go test github.com/libgit2/git2go/v29/... EOF docker build . ``` ``` Step 1/13 : FROM centos:latest ---> 831691599b88 ... Step 11/12 : RUN go mod init example.com/m ---> Running in 2099c98770e8 go: creating new go.mod: module example.com/m Removing intermediate container 2099c98770e8 ---> 7d959c515827 Step 12/12 : RUN go get github.com/libgit2/git2go/v29 ---> Running in fcf0b2af3708 go: downloading github.com/libgit2/git2go v0.28.4 go: downloading github.com/libgit2/git2go/v29 v29.0.2 go: github.com/libgit2/git2go/v29 upgrade => v29.0.2 Removing intermediate container fcf0b2af3708 ---> 990871f39996 Step 13/13 : RUN go test github.com/libgit2/git2go/v29/... ---> Running in ca9cf6bc3144 ok github.com/libgit2/git2go/v29 0.476s Removing intermediate container ca9cf6bc3144 ---> 82e3cb56e9da Successfully built 82e3cb56e9da ```
ishallbethat commented 2020-07-13 07:46:10 -05:00 (Migrated from github.com)

I met the same issue.
my Dockerfile

FROM golang:1.14
# RUN apt-get update && apt-get install libgit2-dev libssh2-1-dev libssl-dev cmake -y
RUN apt-get update && apt-get install openssl apt-transport-https ca-certificates curl g++ gcc libgit2-dev libssh2-1-dev git pkg-config libssl-dev cmake vim -y 
RUN mkdir -p /deploy
ENV PKG_CONFIG_PATH /usr/lib/x86_64-linux-gnu/pkgconfig
# General the build step , so everything ONBUILD
# app name
ARG APP_NAME
ENV WORK_DIR /deploy/${APP_NAME}

# Create app directory
RUN mkdir -p ${WORK_DIR}
WORKDIR ${WORK_DIR}
# Bundle app source
COPY . .
RUN go build .
CMD ["go","run", "*.go"]

And error i get

# github.com/libgit2/git2go/v29
/go/pkg/mod/github.com/libgit2/git2go/v29@v29.0.2/branch.go:211:8: could not determine kind of name for C.git_buf_dispose
The command '/bin/sh -c go build .' returned a non-zero code: 2

my go.md file

module xxx

go 1.14

require (
	cloud.google.com/go v0.60.0 // indirect
	cloud.google.com/go/pubsub v1.3.1
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/ghodss/yaml v1.0.0
	github.com/kr/text v0.2.0 // indirect
	github.com/libgit2/git2go/v29 v29.0.2
	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
	github.com/tidwall/gjson v1.6.0
	github.com/tidwall/sjson v1.1.1
	github.com/vigneshuvi/GoDateFormat v0.0.0-20190923034126-379ee8a8c45f
	golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
	golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
	golang.org/x/text v0.3.3 // indirect
	google.golang.org/api v0.29.0 // indirect
	gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
	gopkg.in/yaml.v2 v2.2.4 // indirect
)
I met the same issue. my Dockerfile ``` FROM golang:1.14 # RUN apt-get update && apt-get install libgit2-dev libssh2-1-dev libssl-dev cmake -y RUN apt-get update && apt-get install openssl apt-transport-https ca-certificates curl g++ gcc libgit2-dev libssh2-1-dev git pkg-config libssl-dev cmake vim -y RUN mkdir -p /deploy ENV PKG_CONFIG_PATH /usr/lib/x86_64-linux-gnu/pkgconfig # General the build step , so everything ONBUILD # app name ARG APP_NAME ENV WORK_DIR /deploy/${APP_NAME} # Create app directory RUN mkdir -p ${WORK_DIR} WORKDIR ${WORK_DIR} # Bundle app source COPY . . RUN go build . CMD ["go","run", "*.go"] ``` And error i get ``` # github.com/libgit2/git2go/v29 /go/pkg/mod/github.com/libgit2/git2go/v29@v29.0.2/branch.go:211:8: could not determine kind of name for C.git_buf_dispose The command '/bin/sh -c go build .' returned a non-zero code: 2 ``` my go.md file ``` module xxx go 1.14 require ( cloud.google.com/go v0.60.0 // indirect cloud.google.com/go/pubsub v1.3.1 github.com/davecgh/go-spew v1.1.1 // indirect github.com/ghodss/yaml v1.0.0 github.com/kr/text v0.2.0 // indirect github.com/libgit2/git2go/v29 v29.0.2 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/tidwall/gjson v1.6.0 github.com/tidwall/sjson v1.1.1 github.com/vigneshuvi/GoDateFormat v0.0.0-20190923034126-379ee8a8c45f golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect golang.org/x/text v0.3.3 // indirect google.golang.org/api v0.29.0 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.2.4 // indirect ) ```
lhchavez commented 2020-07-13 08:00:02 -05:00 (Migrated from github.com)

@IamGabrielWu the golang:1.14 Docker container is based on Buster, which uses libgit 0.27. You might need to either use the v27 branch for git2go or statically build the library for the bundled version.

@IamGabrielWu the [`golang:1.14` Docker container](https://github.com/docker-library/golang/blob/11eef5dfbc243e2c172c0ed0a38f65c0c756486d/1.14/buster/Dockerfile) is based on Buster, which uses [libgit 0.27](https://packages.debian.org/buster/libgit2-dev). You might need to either use the `v27` branch for git2go or statically build the library for the bundled version.
ishallbethat commented 2020-07-13 21:03:20 -05:00 (Migrated from github.com)

thanks @lhchavez
after switching to libgit 0.27 it fixed my problem.
for others having this issue, you can reference my files.
Dockerfile

FROM golang:1.14
# RUN apt-get update && apt-get install libgit2-dev libssh2-1-dev libssl-dev cmake -y
RUN apt-get update && apt-get install openssl apt-transport-https ca-certificates curl g++ gcc libgit2-dev libssh2-1-dev git pkg-config libssl-dev cmake vim -y 
RUN mkdir -p /deploy
ENV PKG_CONFIG_PATH /usr/lib/x86_64-linux-gnu/pkgconfig
# General the build step , so everything ONBUILD
# app name
ARG APP_NAME
ENV WORK_DIR /deploy/${APP_NAME}

# Create app directory
RUN mkdir -p ${WORK_DIR}
WORKDIR ${WORK_DIR}
# Bundle app source
COPY . .
RUN go build .
CMD ["go","run", "*.go"]

And i used "gopkg.in/libgit2/git2go.v27 v27.10.0"

module xxx
go 1.14

require (
	cloud.google.com/go v0.60.0 // indirect
	cloud.google.com/go/pubsub v1.3.1
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/ghodss/yaml v1.0.0
	github.com/kr/text v0.2.0 // indirect
	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
	github.com/tidwall/gjson v1.6.0
	github.com/tidwall/sjson v1.1.1
	github.com/vigneshuvi/GoDateFormat v0.0.0-20190923034126-379ee8a8c45f
	golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
	golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
	golang.org/x/text v0.3.3 // indirect
	google.golang.org/api v0.29.0 // indirect
	gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
	gopkg.in/libgit2/git2go.v27 v27.10.0
	gopkg.in/yaml.v2 v2.2.4 // indirect
)

also i did a bit of adjustment for function "credentialsCallback". It seems there's a bit of change for this function between in git2go v30 and v27.

func credentialsCallback(url string, username_from_url string, allowed_types git.CredType) (git.ErrorCode, *git.Cred) {

	err, cred := git.NewCredSshKey(gitUsername, gitPublicSSHKey, gitPrivateSSHKey, "")
	return git.ErrorCode(err), &cred
}
thanks @lhchavez after switching to libgit 0.27 it fixed my problem. for others having this issue, you can reference my files. Dockerfile ``` FROM golang:1.14 # RUN apt-get update && apt-get install libgit2-dev libssh2-1-dev libssl-dev cmake -y RUN apt-get update && apt-get install openssl apt-transport-https ca-certificates curl g++ gcc libgit2-dev libssh2-1-dev git pkg-config libssl-dev cmake vim -y RUN mkdir -p /deploy ENV PKG_CONFIG_PATH /usr/lib/x86_64-linux-gnu/pkgconfig # General the build step , so everything ONBUILD # app name ARG APP_NAME ENV WORK_DIR /deploy/${APP_NAME} # Create app directory RUN mkdir -p ${WORK_DIR} WORKDIR ${WORK_DIR} # Bundle app source COPY . . RUN go build . CMD ["go","run", "*.go"] ``` And i used "gopkg.in/libgit2/git2go.v27 v27.10.0" ``` module xxx go 1.14 require ( cloud.google.com/go v0.60.0 // indirect cloud.google.com/go/pubsub v1.3.1 github.com/davecgh/go-spew v1.1.1 // indirect github.com/ghodss/yaml v1.0.0 github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/tidwall/gjson v1.6.0 github.com/tidwall/sjson v1.1.1 github.com/vigneshuvi/GoDateFormat v0.0.0-20190923034126-379ee8a8c45f golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect golang.org/x/text v0.3.3 // indirect google.golang.org/api v0.29.0 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/libgit2/git2go.v27 v27.10.0 gopkg.in/yaml.v2 v2.2.4 // indirect ) ``` also i did a bit of adjustment for function "credentialsCallback". It seems there's a bit of change for this function between in git2go v30 and v27. ``` func credentialsCallback(url string, username_from_url string, allowed_types git.CredType) (git.ErrorCode, *git.Cred) { err, cred := git.NewCredSshKey(gitUsername, gitPublicSSHKey, gitPrivateSSHKey, "") return git.ErrorCode(err), &cred } ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jcarr/git2go#617
No description provided.