grype icon indicating copy to clipboard operation
grype copied to clipboard

make bootstrap fails on clean pull of main

Open popey opened this issue 10 months ago • 5 comments

:wave:

What happened:

I followed instructions to build grype from a clone of this repo, but I didn't succeed. Am I holding it wrong? :thinking:

alan@asimo:~/Source/anchore$ git clone https://github.com/anchore/grype
Cloning into 'grype'...
remote: Enumerating objects: 10988, done.
remote: Counting objects: 100% (2157/2157), done.
remote: Compressing objects: 100% (430/430), done.
remote: Total 10988 (delta 1881), reused 1854 (delta 1723), pack-reused 8831
Receiving objects: 100% (10988/10988), 4.39 MiB | 5.09 MiB/s, done.
Resolving deltas: 100% (7401/7401), done.
alan@asimo:~/Source/anchore$ cd grype/
alan@asimo:~/Source/anchore/grype$ go build ./cmd/grype
go: build output "grype" already exists and is a directory
1 alan@asimo:~/Source/anchore/grype$ make bootstrap
mkdir -p ./.tmp
go mod download
curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b ./.tmp/ v0.4.1
[info] using release tag='v0.4.1' version='0.4.1' os='linux' arch='arm64' 
[info] installed ./.tmp//quill 
GO111MODULE=off GOBIN=/home/alan/Source/anchore/grype/.tmp go get -u golang.org/x/perf/cmd/benchstat
go: modules disabled by GO111MODULE=off; see 'go help modules'
make: *** [Makefile:112: bootstrap-tools] Error 1

What you expected to happen:

As I understand it, make bootstrap should pull the necessary tools to run tests and build all artefacts.

How to reproduce it (as minimally and precisely as possible):

Running Ubuntu 23.10 on arm64 with go1.22.1 I tried the build from source instructions in https://github.com/anchore/grype/blob/main/DEVELOPING.md

Anything else we need to know?:

Environment:

  • Output of grype version: Building from source
  • OS (e.g: cat /etc/os-release or similar):
alan@asimo:~$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 23.10"
NAME="Ubuntu"
VERSION_ID="23.10"
VERSION="23.10 (Mantic Minotaur)"
VERSION_CODENAME=mantic
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=mantic
LOGO=ubuntu-logo

popey avatar Mar 26 '24 22:03 popey

Possibly related: https://github.com/anchore/grype/pull/1739 -- it looks like this problem occurs with Go 1.22 but not Go 1.21.

tgerla avatar Mar 28 '24 20:03 tgerla

Dev note: we need to move Grype to Binny (https://pkg.go.dev/github.com/anchore/binny -- already used by Syft) to make the bootstrap process more reliable.

tgerla avatar Mar 28 '24 20:03 tgerla

Just executed make bootstrap today with go version 1.22.1 darwin/amd64. No such problem occurred.

pouyan021 avatar Apr 17 '24 14:04 pouyan021

For those coming to this issue - we're updating the Developing.md and adding some new smoothing/bootstrapping for new users. For now please try the following for the build command:

go build -o dev-grype ./cmd/grype

To run from source:

go run ./cmd/grype/main.go

spiffcs avatar Apr 17 '24 15:04 spiffcs

While possibly a separate bug (let me know if I should file as such), I thought I'd mention here the following as you said that the Developing.md is being smoothed, and this was me running through that documentation.

This line in the Makefile:

SNAPSHOT_BIN := $(realpath $(shell pwd)/$(SNAPSHOT_DIR)/$(OS)-build_$(OS)_amd64_v1/$(BIN))

Has an architecture hardwired into it, which is probably why, later in the make all, this happens on my arm64 macbook pro:

  • docker images
    • building docker image                          image=anchore/grype:debug-ppc64le
    • building docker image                          image=anchore/grype:v0.76.0-arm64v8
    • building docker image                          image=anchore/grype:v0.76.0-ppc64le
    • building docker image                          image=anchore/grype:debug-s390x
    • building docker image                          image=anchore/grype:debug-arm64v8
    • building docker image                          image=anchore/grype:debug
    • building docker image                          image=anchore/grype:latest
    • building docker image                          image=anchore/grype:v0.76.0-s390x
    • took: 8s
  • storing artifacts metadata
    • writing                                        file=snapshot/artifacts.json
  • you are using deprecated options, check the output above for details
  • release succeeded after 42s
  • thanks for using goreleaser!
chmod 755 ""
chmod: : No such file or directory
make: *** [cli] Error 1

Those chmod lines appear originate in the Makefile, as this is the only occurrance of chmod in the file.

.PHONY: cli
cli: $(SNAPSHOT_DIR)  ## Run CLI tests
        chmod 755 "$(SNAPSHOT_BIN)"
        $(SNAPSHOT_BIN) version
        SYFT_BINARY_LOCATION='$(SNAPSHOT_BIN)' \
                go test -count=1 -timeout=15m -v ./test/cli

popey avatar Apr 17 '24 18:04 popey