Skip to content

Commit 2d5b9a8

Browse files
authored
[chore][Makefile] Fix make otel-from-tree (open-telemetry#30333)
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> From testing I found out that golang's `replace` directive didn't work properly when using an absolute path with the `../` included. Using a relative path or an absolute path (without `../` in the middle) resolves the issue. The simple and most clear solution is to use a true absolute path, so I've used `dirname` with the repo's root dir to determine the parent dir. **Link to tracking Issue:** <Issue number if applicable> Fixes open-telemetry#30330 **Testing:** <Describe what testing was performed and which tests were added.> Commands in bug description are all working.
1 parent a572fa2 commit 2d5b9a8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ otel-from-tree:
310310
# 2. Run `make otel-from-tree` (only need to run it once to remap go modules)
311311
# 3. You can now build contrib and it will use your local otel core changes.
312312
# 4. Before committing/pushing your contrib changes, undo by running `make otel-from-lib`.
313-
$(MAKE) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector=$(SRC_ROOT)/../opentelemetry-collector"
313+
$(MAKE) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector=$(SRC_PARENT_DIR)/opentelemetry-collector"
314314

315315
.PHONY: otel-from-lib
316316
otel-from-lib:

Makefile.Common

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ endif
2020

2121
# SRC_ROOT is the top of the source tree.
2222
SRC_ROOT := $(shell git rev-parse --show-toplevel)
23+
# SRC_PARENT_DIR is the absolute path of source tree's parent directory
24+
SRC_PARENT_DIR := $(shell dirname $(SRC_ROOT))
2325

2426
# build tags required by any component should be defined as an independent variables and later added to GO_BUILD_TAGS below
2527
GO_BUILD_TAGS=""

0 commit comments

Comments
 (0)