equinix / metal-cli

Official Equinix Metal CLI
https://deploy.equinix.com/labs/metal-cli
MIT License
59 stars 46 forks source link

MacOS/ARM64 documentation generation/installation quirks #113

Closed vmlemon closed 2 years ago

vmlemon commented 3 years ago

What happened?

I attempted to checkout the repository, and build it using the latest x86-64 MacOS version of Go (go version go1.16.3 darwin/amd64) under Rosetta, on MacOS 11.2.2 (20D80), without an exported PACKET_TOKEN, and received the following surprising error, regarding documentation generation:

tyson@Tysons-Air packet-cli % gmake
/Users/tyson/go/bin/golangci-lint run ./...
rm -rf docs/
mkdir -p docs
go run main.go docs ./docs
Error: Equinix Metal authentication token not provided. Please either set the 'PACKET_TOKEN' environment variable or create a JSON or YAML configuration file.
Usage:
  packet docs [DESTINATION]

Flags:
  -h, --help   help for docs

Global Flags:
      --config string     Path to JSON or YAML configuration file
      --exclude strings   Comma seperated Href references to collapse in results, may be dotted three levels deep
      --include strings   Comma seperated Href references to expand in results, may be dotted three levels deep
  -j, --json              JSON output
      --search string     Search keyword for use in 'get' actions. Search is not supported by all resources.
  -y, --yaml              YAML output

exit status 1
gmake: *** [Makefile:61: generate-docs] Error 1

I also tried to run gmake install, which bailed with the following:

tyson@Tysons-Air packet-cli % sudo gmake install
go install -ldflags "-X github.com/packethost/packet-cli/cmd.Version=0.3.0-10ca3cd -X github.com/packethost/packet-cli/cmd.Build=`git rev-parse --short HEAD`"
mv /bin/packet-cli /bin/packet
mv: rename /bin/packet-cli to /bin/packet: No such file or directory
gmake: *** [Makefile:57: install] Error 1

I assume that there's some issues with locating shared libraries, from within Rosetta, although I haven't had chance to investigate - in any case, I'm brand new to working with the MacOS/ARM64 platform, as well as Packet.

Eventually, after providing a token, and running the gmake again, I was able to receive a working executable:

tyson@Tysons-Air ~ % file go/bin/packet-cli       
go/bin/packet-cli: Mach-O 64-bit executable x86_64

I would expect that the documentation generation wouldn't fail, on account of the missing token environment variable, at least, but I appreciate that the developers of the Metal CLI might not have spent much time, with this new platform.

How can we reproduce it?

Please see the aforementioned details. Thank you for the tool, and I hope this report is useful.

CLI version (packet --version): packet version 0.3.0-10ca3cd

vielmetti commented 3 years ago

Thanks @vmlemon ! What's the output of go version ?

vmlemon commented 3 years ago

Thanks @vmlemon ! What's the output of go version ?

Thanks for the quick response - go version go1.16.3 darwin/amd64 is the reported version. It was installed using an official PKG release. :)

vmlemon commented 3 years ago

FWIW, the GNU Make release is the ARM64 version, from XCode Beta 12.5:

tyson@Tysons-Air ~ % gmake --version
GNU Make 4.3
Built for arm-apple-darwin20.2.0
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

uname -a reports tyson@Tysons-Air ~ % uname -a Darwin Tysons-Air 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64, on this platform.

displague commented 3 years ago

I suspect https://github.com/equinix/metal-cli/pull/150 may have addressed these concerns.

Is this resolved in the main branch, @vmlemon? (note that the project has been renamed from packet-cli to metal-cli, the binary to metal, the config file from ~/.packet-cli.yaml to ~/.config/equinix/metal.yaml. You can run metal init to configure it.)

vmlemon commented 3 years ago

I suspect #150 may have addressed these concerns.

Is this resolved in the main branch, @vmlemon? (note that the project has been renamed from packet-cli to metal-cli, the binary to metal, the config file from ~/.packet-cli.yaml to ~/.config/equinix/metal.yaml. You can run metal init to configure it.)

Thanks for looking into this, and sorry for the delayed response. Sadly, I no longer have access to Metal instances, to test this with, fully, but I was able to get as far as this:

root@Tysons-MacBook-Air metal-cli # gmake
GOBIN=/Users/tyson/metal-cli/hack/tools/bin ./hack/go_install.sh github.com/golangci/golangci-lint/cmd/golangci-lint golangci-lint v1.41.1
rm: /Users/tyson/metal-cli/hack/tools/bin/golangci-lint*: No such file or directory
go: creating new go.mod: module fake/mod
go: downloading github.com/golangci/golangci-lint v1.41.1
go: downloading github.com/fatih/color v1.12.0
go: downloading github.com/gofrs/flock v0.8.0
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/spf13/viper v1.7.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
go: downloading golang.org/x/tools v0.1.3
go: downloading github.com/go-critic/go-critic v0.5.6
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading github.com/sirupsen/logrus v1.8.1
go: downloading github.com/stretchr/testify v1.7.0
go: downloading github.com/golangci/revgrep v0.0.0-20210208091834-cd28932614b5
go: downloading golang.org/x/sys v0.0.0-20210510120138-977fb7262007
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading 4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a
go: downloading github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24
go: downloading github.com/alexkohler/prealloc v1.0.0
go: downloading github.com/ashanbrown/forbidigo v1.2.0
go: downloading github.com/ashanbrown/makezero v0.0.0-20210520155254-b6261585ddde
go: downloading github.com/bkielbasa/cyclop v1.2.0
go: downloading github.com/bombsimon/wsl/v3 v3.3.0
go: downloading github.com/charithe/durationcheck v0.0.8
go: downloading github.com/daixiang0/gci v0.2.8
go: downloading github.com/denis-tingajkin/go-header v0.4.2
go: downloading github.com/esimonov/ifshort v1.0.2
go: downloading github.com/fzipp/gocyclo v0.3.1
go: downloading github.com/golangci/misspell v0.3.5
go: downloading github.com/gostaticanalysis/forcetypeassert v0.0.0-20200621232751-01d4955beaa5
go: downloading github.com/gostaticanalysis/nilerr v0.1.1
go: downloading github.com/jgautheron/goconst v1.5.1
go: downloading github.com/jingyugao/rowserrcheck v1.1.0
go: downloading github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af
go: downloading github.com/julz/importas v0.0.0-20210419104244-841f0c0fe66d
go: downloading github.com/kisielk/errcheck v1.6.0
go: downloading github.com/kulti/thelper v0.4.0
go: downloading github.com/kunwardeep/paralleltest v1.0.2
go: downloading github.com/ldez/gomoddirectives v0.2.1
go: downloading github.com/ldez/tagliatelle v0.2.0
go: downloading github.com/kyoh86/exportloopref v0.1.8
go: downloading github.com/matoous/godox v0.0.0-20210227103229-6504466cf951
go: downloading github.com/mbilski/exhaustivestruct v1.2.0
go: downloading github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81
go: downloading github.com/mgechev/revive v1.0.7
go: downloading github.com/moricho/tparallel v0.2.1
go: downloading github.com/nishanths/exhaustive v0.1.0
go: downloading github.com/nishanths/predeclared v0.2.1
go: downloading github.com/polyfloyd/go-errorlint v0.0.0-20210510181950-ab96adb96fea
go: downloading github.com/ryancurrah/gomodguard v1.2.2
go: downloading github.com/sanposhiho/wastedassign/v2 v2.0.6
go: downloading github.com/securego/gosec/v2 v2.8.0
go: downloading github.com/sourcegraph/go-diff v0.6.1
go: downloading github.com/ssgreg/nlreturn/v2 v2.1.0
go: downloading github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b
go: downloading github.com/tetafro/godot v1.4.7
go: downloading github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94
go: downloading github.com/tomarrell/wrapcheck/v2 v2.1.0
go: downloading github.com/tommy-muehle/go-mnd/v2 v2.4.0
go: downloading github.com/ultraware/funlen v0.0.3
go: downloading github.com/yeya24/promlinter v0.1.0
go: downloading honnef.co/go/tools v0.2.0
go: downloading mvdan.cc/gofumpt v0.1.1
go: downloading mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7
go: downloading github.com/quasilyte/go-ruleguard v0.3.4
go: downloading github.com/hashicorp/errwrap v1.0.0
go: downloading golang.org/x/text v0.3.5
go: downloading github.com/gostaticanalysis/comment v1.4.1
go: downloading github.com/gostaticanalysis/analysisutil v0.4.1
go: downloading github.com/ettle/strcase v0.1.1
go: downloading github.com/fatih/structtag v1.2.0
go: downloading github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354
go: downloading github.com/prometheus/client_golang v1.7.1
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/google/go-cmp v0.5.4
go: downloading github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af
go: downloading github.com/olekukonko/tablewriter v0.0.5
go: downloading github.com/prometheus/common v0.10.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/golang/protobuf v1.4.3
go: downloading github.com/prometheus/procfs v0.1.3
go: downloading github.com/mattn/go-runewidth v0.0.9
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading google.golang.org/protobuf v1.25.0
go get: added github.com/golangci/golangci-lint v1.41.1
/Users/tyson/metal-cli/hack/tools/bin/golangci-lint-v1.41.1 run -v --fast=false
INFO [config_reader] Config search paths: [./ /Users/tyson/metal-cli /Users/tyson /Users /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (imports|compiled_files|exports_file|files|name|types_sizes|deps) took 3.875318208s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.28475ms 
INFO [linters context/goanalysis] analyzers took 7.950014132s with top 10 stages: buildir: 4.813216211s, fact_deprecated: 350.201457ms, inspect: 281.123545ms, fact_purity: 256.602461ms, nilness: 219.814141ms, ctrlflow: 207.125495ms, printf: 169.361582ms, directives: 145.558579ms, SA5012: 134.044539ms, typedness: 108.999499ms 
INFO [runner] processing took 2.124µs with stages: max_same_issues: 416ns, max_from_linter: 291ns, nolint: 291ns, skip_dirs: 250ns, path_shortener: 167ns, uniq_by_line: 167ns, diff: 166ns, source_code: 42ns, sort_results: 42ns, path_prettifier: 42ns, severity-rules: 42ns, cgo: 42ns, filename_unadjuster: 42ns, exclude-rules: 42ns, max_per_file_from_linter: 41ns, skip_files: 41ns, identifier_marker: 0s, exclude: 0s, path_prefixer: 0s, autogenerated_exclude: 0s 
INFO [runner] linters took 2.036332792s with stages: goanalysis_metalinter: 2.036293708s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 61 samples, avg is 163.7MB, max is 476.0MB 
INFO Execution took 5.923517208s                  
rm -rf docs/
mkdir -p docs
go run ./cmd/metal docs ./docs

Followed by:

root@Tysons-MacBook-Air metal-cli # gmake install
go install -ldflags "-X github.com/equinix/metal-cli/cmd.Version=0.6.0-alpha3 v0.6.0-10e9e19 -X github.com/equinix/metal-cli/cmd.Build=10e9e19" ./cmd/metal
# github.com/equinix/metal-cli/cmd/metal
usage: link [options] main.o
  -B note
        add an ELF NT_GNU_BUILD_ID note when using ELF
  -E entry
        set entry symbol name
  -H type
        set header type
  -I linker
        use linker as ELF dynamic linker
  -L directory
        add specified directory to library path
  -R quantum
        set address rounding quantum (default -1)
  -T address
        set text segment address (default -1)
  -V    print version and exit
  -X definition
        add string value definition of the form importpath.name=value
  -a    no-op (deprecated)
  -aslr
        enable ASLR for buildmode=c-shared on windows (default true)
  -benchmark string
        set to 'mem' or 'cpu' to enable phase benchmarking
  -benchmarkprofile base
        emit phase profiles to base_phase.{cpu,mem}prof
  -buildid id
        record id as Go toolchain build id
  -buildmode mode
        set build mode
  -c    dump call graph
  -compressdwarf
        compress DWARF if possible (default true)
  -cpuprofile file
        write cpu profile to file
  -d    disable dynamic executable
  -debugppc64textsize int
        debug PPC64 text section max
  -debugtramp int
        debug trampolines
  -dumpdep
        dump symbol dependency graph
  -extar string
        archive program for buildmode=c-archive
  -extld linker
        use linker when linking in external mode
  -extldflags flags
        pass flags to external linker
  -f    ignore version mismatch
  -g    disable go package data checks
  -h    halt on error
  -importcfg file
        read import configuration from file
  -installsuffix suffix
        set package directory suffix
  -k symbol
        set field tracking symbol
  -libgcc string
        compiler support lib for internal linking; use "none" to disable
  -linkmode mode
        set link mode
  -linkshared
        link against installed Go shared libraries
  -memprofile file
        write memory profile to file
  -memprofilerate rate
        set runtime.MemProfileRate to rate
  -msan
        enable MSan interface
  -n    dump symbol table
  -o file
        write output to file
  -pluginpath string
        full path name for plugin
  -r path
        set the ELF dynamic linker search path to dir1:dir2:...
  -race
        enable race detector
  -s    disable symbol table
  -strictdups int
        sanity check duplicate symbol contents during object file reading (1=warn 2=err).
  -tmpdir directory
        use directory for temporary files
  -v    print link trace
  -w    disable DWARF generation
gmake: *** [Makefile:64: install] Error 2
cprivitere commented 2 years ago

We're publishing M1 versions of metal-cli as of today. So I anticipate this is all resolved. Going to mark this as closed for now, if there are any problems, please open a new issue so we can start fresh against the current code base.