kovetskiy / mark

Sync your markdown files with Confluence pages.
https://samizdat.dev
Other
988 stars 147 forks source link

go get/install fails in AWS CodeBuild runtime #340

Closed Nr18 closed 1 year ago

Nr18 commented 1 year ago

What happened? I am trying to install mark in a AWS CodeBuild environment and I get the following error:

/go/pkg/mod/github.com/dreampuf/mermaid.go@v0.0.12-0.20230620030857-f06bfbab37fc/mermaid.go:5:2: package embed is not in GOROOT (/root/.goenv/versions/1.14.15/src/embed)

What did you expect to happen? That the binary would be installed and usable within the CodeBuild environment.

How can we reproduce the behavior you experienced? Steps to reproduce the behavior:

  1. Create a CodeBuild Project with the following build spec and run it:
# https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
version: 0.2
phases:
  install:
    runtime-versions:
      python: 3.9
      nodejs: 12
    commands:
      - pip install --upgrade pip
      - pip install --upgrade awscli aws-sam-cli
  build:
    commands:
      - pwd
      - go env
      - GO111MODULE=on GOPATH=$(shell go env GOPATH) go get github.com/kovetskiy/mark@9.7.0

In case this is related to specific markdown, please provide a minimal markdown example here.

Information (please complete the following information):

Logs or other output

$ pwd
/codebuild/output/src386466225/src/git-codecommit.eu-west-1.amazonaws.com/v1/repos/sync-confluence

$ 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="/go:/codebuild/output/src386466225"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/root/.goenv/versions/1.14.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/.goenv/versions/1.14.15/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build377053330=/tmp/go-build -gno-record-gcc-switches"

$ GO111MODULE=on GOPATH=$(shell go env GOPATH) go get github.com/kovetskiy/mark@9.7.0
go: downloading github.com/kovetskiy/mark v0.0.0-20230705154055-d147aac98bcf
go: github.com/kovetskiy/mark 9.7.0 => v0.0.0-20230705154055-d147aac98bcf
go: downloading github.com/urfave/cli/v2 v2.25.7
go: downloading github.com/kovetskiy/lorg v1.2.0
go: downloading github.com/reconquest/pkg v1.3.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/yuin/goldmark v1.5.4
go: downloading github.com/zazab/zhash v0.0.0-20210630080733-6e809466f8d3
go: downloading github.com/dreampuf/mermaid.go v0.0.12-0.20230620030857-f06bfbab37fc
go: downloading github.com/kovetskiy/gopencils v0.0.0-20230119081704-a73db75b2f69
go: downloading github.com/reconquest/regexputil-go v0.0.0-20160905154124-38573e70c1f4
go: downloading github.com/reconquest/karma-go v1.2.0
go: downloading golang.org/x/tools v0.10.0
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.2
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading github.com/reconquest/cog v0.0.0-20210820140837-c5c4e8f49c65
go: downloading github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
go: downloading github.com/BurntSushi/toml v1.3.2
go: downloading github.com/chromedp/chromedp v0.9.1
go: downloading github.com/chromedp/cdproto v0.0.0-20230605001715-1e95ea08ffe6
go: downloading github.com/mailru/easyjson v0.7.7
go: downloading github.com/gobwas/ws v1.1.0
go: downloading github.com/gobwas/pool v0.2.1
go: downloading github.com/gobwas/httphead v0.1.0
go: downloading github.com/josharian/intern v1.0.0
go: downloading github.com/chromedp/sysutil v1.0.0
go: downloading golang.org/x/sys v0.9.0
/go/pkg/mod/github.com/dreampuf/mermaid.go@v0.0.12-0.20230620030857-f06bfbab37fc/mermaid.go:5:2: package embed is not in GOROOT (/root/.goenv/versions/1.14.15/src/embed)

Additional context N/A

mrueg commented 1 year ago

The go version 1.14.15 sounds like the environment is pretty old and I would assume that's why it's not working. Have you tried upgrading golang to a later version?

Nr18 commented 1 year ago

@mrueg you are the man!

Solution was to update the CodeBuild environment, because aws/codebuild/amazonlinux2-x86_64-standard:3.0 only supported older versions of go:

Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
PrivilegedMode: true

Next in the buildspec.yml I selected the newer runtimes:

phases:
  install:
    runtime-versions:
      python: 3.11
      nodejs: 18
      golang: 1.20

And I switched back to:

go install github.com/kovetskiy/mark@9.7.0

That solved my problem, thanks!

mrueg commented 1 year ago

Great to hear it's working! Be aware that you might need to quote the go version, as in yaml 1.20 is treated as a number and the parser might return 1.2.