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

Compiling from the source package fails with the error: "/internal/tools/tools.go: No such file or directory" #10060

Open
thehaven opened this issue May 1, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@thehaven
Copy link

thehaven commented May 1, 2024

Describe the bug
Compiling from the source package fails with the error:

/bin/bash: line 1: /internal/tools/tools.go: No such file or directory

This seems to be because SRC_ROOT requires a git based checkout as per:

Makefile.Common
14:# SRC_ROOT is the top of the source tree.
15:SRC_ROOT := $(shell git rev-parse --show-toplevel)
17:TOOLS_MOD_DIR   := $(SRC_ROOT)/internal/tools
18:TOOLS_BIN_DIR   := $(SRC_ROOT)/.tools

When git rev-parse --show-toplevel fails to run SRC_ROOT="" and the pathing gets screwed up.

Steps to reproduce

Download and run make:

❯ curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector/archive/refs/tags/v0.99.0.tar.gz && tar -xvzf v0.99.0.tar.gz
❯ cd opentelemetry-collector-0.99.0
❯ make
go: downloading github.com/stretchr/testify v1.9.0
go: downloading go.opentelemetry.io/contrib/config v0.5.0
go: downloading google.golang.org/grpc v1.63.2
go: downloading go.uber.org/multierr v1.11.0
go: downloading go.uber.org/zap v1.27.0
go: downloading github.com/hashicorp/go-version v1.6.0
go: downloading github.com/shirou/gopsutil/v3 v3.24.3
go: downloading go.opentelemetry.io/otel/metric v1.25.0
go: downloading go.opentelemetry.io/otel/trace v1.25.0
go: downloading go.opentelemetry.io/otel v1.25.0
go: downloading github.com/json-iterator/go v1.1.12
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.25.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0
go: downloading go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.25.0
go: downloading go.opentelemetry.io/otel/sdk/metric v1.25.0
go: downloading go.opentelemetry.io/otel/sdk v1.25.0
go: downloading github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1
go: downloading github.com/knadh/koanf/maps v0.1.1
go: downloading github.com/knadh/koanf/providers/confmap v0.1.0
go: downloading github.com/knadh/koanf/v2 v2.1.1
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading golang.org/x/sys v0.18.0
go: downloading go.opentelemetry.io/proto/otlp v1.2.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda
go: downloading google.golang.org/protobuf v1.33.0
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/go-logr/logr v1.4.1
go: downloading github.com/cenkalti/backoff/v4 v4.3.0
go: downloading golang.org/x/net v0.23.0
go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de
go: downloading golang.org/x/text v0.14.0
fatal: not a git repository (or any parent up to mount point /storage)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
/bin/bash: line 1: /internal/tools/tools.go: No such file or directory
make: *** No rule to make target '/.tools/addlicense', needed by 'checklicense'.  Stop.

What did you expect to see?
Checking out the git repo, switching to tag v0.99.0 and running make works just fine. I expected it to work from package source as well.

@thehaven thehaven added the bug Something isn't working label May 1, 2024
@mx-psi
Copy link
Member

mx-psi commented May 2, 2024

@thehaven Note that make will eventually (after running tests and linters) build a test version of the Collector.

If you want to build a (usable on prod) Collector from source I would recommend using the Collector builder. By default it will generate a binary, but you can also use --skip-compilation to generate the code, inspect it and then build it yourself

@thehaven
Copy link
Author

thehaven commented May 3, 2024

Thanks, I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants