Skip to content

Commit 094b0da

Browse files
fix: make install reports location, version, PATH and shadowing problems
1 parent 7ade160 commit 094b0da

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎Makefile‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,24 @@ $(BUILDDIR):
2929
build: $(BUILDDIR)
3030
go build $(GOFLAGS) $(LDFLAGS) -o $(BUILDDIR)$(SEP)$(BINARY) $(CMD)
3131

32-
## install: install to $$GOPATH/bin (or ~/go/bin)
32+
## install: build and install to $GOBIN (or $GOPATH/bin)
3333
install:
3434
go install $(GOFLAGS) $(LDFLAGS) $(CMD)
35+
@BIN="$$(go env GOBIN)"; \
36+
if [ -z "$$BIN" ]; then BIN="$$(go env GOPATH)/bin"; fi; \
37+
echo "installed: $$BIN/$(BINARY)"; \
38+
"$$BIN/$(BINARY)" --version; \
39+
case ":$$PATH:" in \
40+
*"$$BIN"*) ;; \
41+
*) echo "WARNING: $$BIN is not on your PATH, so '$(BINARY)' will not be found."; \
42+
echo " Add this to ~/.bashrc or ~/.zshrc, then restart your shell:"; \
43+
echo " export PATH=\"\$$PATH:$$BIN\""; ;; \
44+
esac; \
45+
FOUND="$$(command -v $(BINARY) 2>/dev/null || true)"; \
46+
if [ -n "$$FOUND" ] && [ "$$FOUND" != "$$BIN/$(BINARY)" ]; then \
47+
echo "WARNING: '$$FOUND' shadows the new binary (shell picks the first match on PATH)."; \
48+
echo " Remove it or put $$BIN earlier on PATH to use the new build."; \
49+
fi
3550

3651
## run: build and run
3752
run: build

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ brew install programmersd21/flow/flow
3333
go install github.com/programmersd21/flow/cmd/flow@latest
3434
```
3535

36+
Make sure `$(go env GOPATH)/bin` is on your `PATH`, otherwise your shell
37+
won't find the new binary (and a stale copy elsewhere can shadow it —
38+
`make install` warns about both).
39+
3640
or download a binary from [releases](https://github.com/programmersd21/flow/releases).
3741

3842
## usage

0 commit comments

Comments
 (0)