본문 바로가기
Solution

[Docker] gradlew 파일 CRLF형식 오류(did not complete successfully: exit code: 127)

by 호호호호히히히히 2025. 9. 22.
반응형

도커를 도입하고있습니다.

푸시 전 로컬에서 수행해 보고 싶은데 로컬에서 아무리 돌려봐도

 

failed to solve: process "/bin/sh -c ./gradlew clean build -x test" did not complete successfully: exit code: 127

에러가 납니다. 파일 형식에 개행으로 인식되고있는게 있기 때문인데


gradlew 파일이 CRLF형식임. 난 맥인데.. 왜..?

 

file gradlew

gradlew: POSIX shell script text executable, Unicode text, UTF-8 text, with CRLF line terminators

with CRLF line terminators 문제임.


RUN sed -i 's/\r$//' gradlew && chmod +x gradlew

이렇게 설정하고 돌리면 정상 구동이 됩니다.

혹은 아래 방법으로 해도 구동이 됩니다.

 

sed -i '' 's/\r$//' gradlew

file gradlew               

gradlew: POSIX shell script text executable, Unicode text, UTF-8 text

 

하지만 이런 방법으로 개행을 없애고 싶지 않습니다.

 

원격 저장소 파일이 문제인가. 내 로컬이 문제인가.. 

 

git config --get core.autocrlf
  • 출력이 true → 체크아웃할 때 LF → CRLF 변환이 일어난 것 (윈도우 스타일).
  • 출력이 input → 커밋 시에만 CRLF → LF 변환, 체크아웃할 때는 안 건드림.
  • 출력이 false (unset) → 아예 변환 안 함.

원격 저장소도 확인

git show origin/main:services/partner-api/gradlew | file -

/dev/stdin: POSIX shell script text executable, Unicode text, UTF-8 text

 

청천벽력...

즉.. 내 로컬만이 문제임. 맥인데 언제 이렇게 또 설정이..


로컬 바꾸기

git config --global core.autocrlf input

-- 현재 저장소 적용

git config core.autocrlf input

-- 이상한 파일 복구 (무서우면 브랜치 다시 땡기기)

git rm --cached -r .
git reset --hard

 

정상 체크 아웃 확인합니다.

 

행복 빌드

docker-compose up --build

 

반응형

댓글