[Rtips] m1 mac에서 패키지 인스톨 문제 해결하기

R m1 package install xcode fortran compiler Rtips iamdt

공식 문서 링크: https://mac.r-project.org/tools/

true
2022-09-14
Photo by Maxim Hopman on Unsplash

한줄요약

공식 문서를 확인하자.

최근 mac에서 R의 패키지를 설치할 때 컴파일 단계에서 문제가 생기는 경우가 있습니다. gfortran 이 없다는 식의 에러인데요. 보통 xcode가 설치가 안되어 있거나 brew install gcc 정도로 해결되었던 문제라 넘어갔었습니다. 근데, 최근에 mac을 다시 설정할 일이 생겨서 살펴보니 같은 문제가 발생했습니다.

해결방법

총 2개를 설치하라고 안내하고 있습니다.

  1. xcode

mac용 개발도구인 xcode를 설지합니다. 어떤 방식으로 설치해도 문제는 없는 것 같습니다만, 터미널에서 아래 명령으로 설치할 수 있습니다.

sudo xcode-select --install
  1. GNU fortran

아쉽게도 포트란 컴파일러가 xcode에 포함되어 있지 않답니다. 인텔 맥인지, m1 맥인지에 따라 방법이 다릅니다.

2.1 인텔 맥

dmg 설치 파일을 제공합니다. /usr/local/gfortran/bin 위치에 설치를 하나봅니다. export PATH=$PATH:/usr/local/gfortran/bin 로 PATH를 추가해야 합니다.

2.2 m1 맥

m1 맥용 컴파일러를 다운로드 받아서 압축을 풀어야 합니다. 다운로드 받은 파일이 있는 위치에 가서 아래 명령을 터미널에서 수행합니다.

sudo tar fxz gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz -C /

그리고 마찬가지로 export PATH=$PATH:/opt/R/arm64/gfortran/bin 로 경로를 추가합니다.

모든 것이 끝나면 이제 문제없이 패키지를 컴파일하여 설치할 겁니다.

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-NC-ND 4.0. Source code is available at https://github.com/mrchypark/mrchypark.github.io, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Park (2022, Sept. 14). mrchypark: [Rtips] m1 mac에서 패키지 인스톨 문제 해결하기. Retrieved from https://mrchypark.github.io/post/rtips-m1-mac에서-패키지-인스톨-문제-해결하기/

BibTeX citation

@misc{park2022[rtips],
  author = {Park, Chanyub},
  title = {mrchypark: [Rtips] m1 mac에서 패키지 인스톨 문제 해결하기},
  url = {https://mrchypark.github.io/post/rtips-m1-mac에서-패키지-인스톨-문제-해결하기/},
  year = {2022}
}