Skip to content

docs: document the pre-commit tool overrides and the Go-upgrade trap - #43

Merged
pignuante merged 1 commit into
mainfrom
docs/pre-commit-tool-overrides
Nov 22, 2026
Merged

pignuante merged 1 commit into
mainfrom
docs/pre-commit-tool-overrides

Conversation

@pignuante

Copy link
Copy Markdown
Contributor

한 줄 요약

CLAUDE.md의 Pre-commit Hooks 절에 한 문단을 더합니다. 훅은 이미 PRETTIER와 GOLANGCI_LINT 환경 변수를 도구 위치보다 먼저 보지만, 문서에는 그 사실이 없었습니다. Go 버전 관리자가 Go 버전마다 GOPATH를 따로 두면, Go를 올린 뒤 훅이 도구를 못 찾아 모든 커밋이 막힙니다. 문단은 그 상황과 복구 방법을 적습니다. 코드 변경이 없고 제품 변화도 없습니다.

이 PR을 읽는 데 필요한 배경 지식

1. pre-commit 훅의 도구 찾기

.githooks/pre-commit 4–5행은 golangci-lint와 prettier를 이 순서로 찾습니다.

  1. GOLANGCI_LINT, PRETTIER 환경 변수가 비어 있지 않으면 그 경로
  2. PATH에서 찾은 명령
  3. $(go env GOPATH)/bin 아래 파일

셋 다 실패하면 훅은 검사 전에 종료하고 커밋은 만들어지지 않습니다.

2. GOPATH를 Go 버전마다 나누는 도구

goenv 같은 버전 관리자는 GOPATH를 Go 버전별 폴더로 둘 수 있습니다. 예를 들어 Go를 1.27.1에서 1.27.3으로 올리면 go env GOPATH가 ~/go/1.27.1에서 ~/go/1.27.3으로 바뀝니다. go install로 받은 prettier는 옛 폴더에 남습니다.

무엇이 문제였나

상황 이전
Go 업그레이드 뒤 첫 커밋 훅이 prettier를 못 찾아 "Run 'make setup'"을 출력하고 종료
안내된 복구 make setup은 prettier@latest를 받으므로, 옛 버전과 서식 결과가 달라질 수 있음
override 훅이 지원하지만 CLAUDE.md에 없음

어떻게 고쳤나

Pre-commit Hooks 절의 도구 누락 설명 바로 아래에 문단 하나를 넣었습니다.

  1. PRETTIER·GOLANGCI_LINT가 두 찾기 단계보다 먼저 쓰인다는 것과 사용 예
  2. Go 버전마다 GOPATH를 나누는 환경에서 업그레이드 뒤 도구를 못 찾게 되는 이유
  3. 옛 바이너리의 버전을 go version -m으로 읽어 같은 버전으로 다시 설치하라는 권고. go version -m은 바이너리를 실행하지 않고 빌드 정보만 읽습니다.

기각한 대안

  1. make setup을 버전 고정 설치로 바꾸기: 리포가 prettier 버전을 어디에도 고정하지 않으므로 고정할 버전을 먼저 정해야 합니다. 이 PR 범위 밖입니다.
  2. 훅이 다른 GOPATH까지 뒤지게 하기: 버전 관리자마다 폴더 구조가 달라 훅이 특정 도구에 묶입니다.

기대되는 효과

상황 이전 이후
훅이 도구를 못 찾을 때 문서에 우회 방법이 없음 override 한 줄로 커밋 가능
도구 재설치 make setup(@latest) 같은 버전으로 재설치해 서식 결과 유지

docs: 커밋이라 머지해도 릴리스는 나오지 않습니다.

검증

확인 결과
훅의 override 우선순위 .githooks/pre-commit 4–5행: ${PRETTIER:-…}, ${GOLANGCI_LINT:-…}
main의 CLAUDE.md에 override 언급 git grep -n 'PRETTIER|GOLANGCI_LINT' eece1a0 -- CLAUDE.md 결과 0줄
make setup의 설치 버전 Makefile 47행 prettier@latest
재설치 절차 go-prettier v1.33.3을 새 GOPATH에 설치한 뒤 override 없이 커밋, 훅 통과
pre-commit go fmt, prettier, go mod tidy, golangci-lint 통과

범위 밖 (후속 추적)

  1. prettier 버전 고정(make setup, CI): 고정할 버전과 위치를 먼저 정해야 합니다. 미이슈화.

.githooks/pre-commit already honours PRETTIER and GOLANGCI_LINT ahead
of its PATH and GOPATH lookups (lines 4-5), but CLAUDE.md never said
so; it only described the hook exiting when a tool is missing.

The common way to hit that exit is a Go upgrade under a version
manager that keeps one GOPATH per Go version: go env GOPATH moves to
the new version's directory, the tools stay behind in the old one, and
every commit fails. The new paragraph names the overrides and says to
reinstall at the version the old binary reports, because make setup
installs @latest and can format the tree differently.
@pignuante pignuante self-assigned this Nov 19, 2026
@pignuante
pignuante merged commit 34d8d0f into main Nov 22, 2026
9 checks passed
@pignuante
pignuante deleted the docs/pre-commit-tool-overrides branch November 22, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant