Homebrew 정리

Homebrew

Homebrew란 간단히 말해서 Mac용 패키지 관리자이다. 리눅스에서 데비안, 우분투는 apt-get-install로 패키지를 알아서 설치하고 CentOS 는 yum으로 설치하는데 Mac도 Homebrew라는 패키지관리자를 통해서 패키지를 쉽게 설치할수 있다. (brew를 통해 설치하면 패키지의 의존하는 패키지들도 알아서 설치해준다.) 개발하다가 또는 웹사이트를 탐험하다가 소프트웨어 및 사용하는 툴의 플러그인 들을 설치하는 방법들을 보면 Homebrew로 설치하라고 하는 README를 많이 볼 수 있다. 그런점을 봐도 Mac을 사용한다면 처음에 해야할 일은 아마도 Homebrew를 설치하는 일이 아닌가 싶다. Homebrew를 통해서 단순히 패키지만을 설치할 수 있을뿐만 아니라 구글 Chrome 이나 Java JDK 등 cask 명령어를 통해 응용 프로그램을 쉽게 설치할 수 있다.

그럼 일단 Homebrew를 설치해보자.

지금의 설명은 전부 다 Homebrew의 홈페이지에 자세히 나와있다. Hombrew 사이트 친절하게 한글로도 번역이되어있다.

Hombrew를 설치하는 방법은 간단히 Mac의 터미널을 실행시키고 아래의 명령어만 입력하면된다.

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Homebrew를 설치를 완료하면 이제 brew 명령어를 통해서 패키지를 설치할 수 있다.

1
brew install [패키지명]

brew는 똑같은 패키지라도 버전별로 다르게 다운로드 할 수 있다.

Homebrew는 전용 디렉터리에 패키지를 설치하고 환경설정 및 binary 파일을 심볼릭 링크로 연결시켜준다.

전용 디렉터리의 위치는 /usr/local/Cellar 에 있다. Cellar 밑으로 들어가보면 brew로 설치한 패키지 목록들이 나타낸다.

직접 경로로 들어가보지 않고 brew로 설치한 패키지 목록을 나타내는 명령어는 아래와 같다.

1
brew list

brew 명령어

brew command 퍼옴..

brew에서 설치할 수 있는 패키지들을 formula 라고 한다.

자주쓰이는 명령어는

1
2
3
4
5
6
7
8
brew list	//현재 설치되어있는 패키지 목록
brew search [formular] //패키지 검색
brew remove [formula] //패키지 삭제 (uninstall도 가능)
brew doctor // brew 사용시 오류를 체크
brew info [formula] //패키지 정보
brew upgrade [formual] // 패키지를 안써주면 현재 설치되어있는 패키지 전부 업그레이드 패키지 를 명시해주면 명시된 패키지만 업데이트
brew update // Homebrew 업데이트
brew cleanup //패키지의 모든 과거버전을 제거

아래 표는 참고로..

Command Consequence
brew install foo Installs foo
brew install --HEAD foo Installs the HEAD version of foo, if foo defines such a version.
brew install --force --HEAD foo Installs a newer HEAD version of foo.
brew search Lists all formula that you can install
brew search foo Searches for foo in formula available to install
brew search /foo/ Same as above but parses /foo/ as a regex
brew list Lists all installed formulae
brew list foo Lists the installed files for foo
brew info --github foo Open your browser at the Github History page for formula foo
brew info Summarises all installed Homebrew packages
brew info foo Gives all available information for installed or not installed formula foo
brew home Open’s Homebrew’s homepage in your default browser
brew home foo Opens foo’s homepage in your default browser
brew update Update homebrew formulae and homebrew itself
brew remove foo Uninstalls foo
brew create [url] Generates a formula for the downloadable file at url and opens it in TextMate 1
brew create url-of-tarball --cache Generates a formula, then downloads the tarball. Adds the md5 to the formula template for you
brew create --macports foo Open your browser at the MacPorts package search page, so you can see how they do foo
brew create --fink foo Same thing, but for Fink
brew edit foo Opens the formula in TextMate
brew link foo Symlinks all of foo’s installed files into the Homebrew prefix 2
brew unlink foo Unsymlinks foo from the Homebrew prefix
brew prune Removes dead symlinks from the Homebrew prefix 3
brew outdated Shows formula that have an updated version available . To install the new version of foo: brew install foo
brew --config Print some useful system configuration to the console
brew --prefix Display the real path to your Homebrew prefix (Usually /usr/local)
brew --prefix (formula) Display the path where this formula is installed
brew --cellar Display the real path to your Homebrew Cellar (Usually /usr/local/Cellar)
brew --cache Display the real path to where Homebrew caches downloads (Usually ~/Library/Caches/Homebrew)
brew doctor Checks your installation for common issues
brew audit Audits all formulae for common code and style issues
brew cleanup foo For all installed or specific formulae, removes any older versions from the cellar 4

Homebrew Cask

Homebrew Cask는 Homebrew의 확장 프로그램(?) 쯤으로 생각하면 되고 MacOS 응용 프로그램과 대형 바이너리 파일들을 우아하고(?) 단순하게 그리고 빠르게 받을 수 있게 해준다고 공식 홈페이지에 나와있다.

Homebrew Cask

당연한 이야기지만 Cask를 사용하기 위해서는 먼저 Homebrew를 설치해야 한다.

brew cask 명령어를 사용하기 전에 아래의 명령어를 일단 실행해야한다.

1
brew tap caskroom/cask

우리가 보통 응용 프로그램을 다운로드 받을 때 받고싶은 응용 프로그램을 인터넷에 검색해서 공식 사이트에 들어가서 다운로드 받아서 설치까지 진행해야하는 번거로움(?)이 있지만 Homebrew Cask 를 사용하면 터미널을 키고 그냥 아래의 명령어만 쳐주면 된다.

1
brew cask install google-chrome

cask로 설치한 응용프로그램의 위치는 /usr/local/Caskroom 에 있다.

Cask 명령어

cask 명령어는 기존 brew 명령어와 다를게 없다. 단지 앞에 cask 만 하나 더 들어가있다.

1
2
3
brew cask search <program>	//응용 프로그램 검색
brew cask install <program> //응용 프로그램 설치
brew cask uninstall <program> //응용 프로그램 제거

나는 현재 java를 버전별로 cask 명령어를 통해 설치해 놓음

Share