Skip to content

Instantly share code, notes, and snippets.

@ikaruce
Created February 12, 2015 07:51
Show Gist options
  • Save ikaruce/09c66ba89f8d6c8d3378 to your computer and use it in GitHub Desktop.
Save ikaruce/09c66ba89f8d6c8d3378 to your computer and use it in GitHub Desktop.
Gem file download with all dependencies.

Gem file download with all dependencies.

( 원본 : http://stackoverflow.com/a/9312332/3081313)

인터넷이 연결되지 않은 상태에서 Gem file을 설치하려면 Gem 파일을 다운 받아 --local 옵션을 주어서 설치할 수 있는데, 의존성을 가진 Gem 파일들을 모두 다운 받아야 한다. 몇개 안되는 경우 하나하나 다운받으면 되지만, 의존성이 많은 경우나 의존성을 가진 Gem이 다른 Gem에 또 의존성을 가지는 경우 모두 다운 받으려면 상당히 많은 고통을 준다. 이 글은 이런 경우 의존성을 가지는 Gem들을 bundler를 통해 한꺼번에 다운 받아서 설치할 수 있는 방법을 설명한다.

1. 먼저 인터넷이 연결된 장비에서 새로운 폴더를 생성하고 Gemfile을 생성한다.

$ mkdir tempfolder && cd $_
$ touch Gemfile

2. Gemfile에 source와 다운 받을 Gem 파일을 작성한다.

# 예를 들어 rails 를 다운 받는다고 하면. 
$ vi Gemfile
...
# Gemfile start
source "http://rubygems.org"
gem "rails"
# Gemfile end 

3. bundle install을 실행한다. 이러면 의존성을 가지는 Gem들을 다운받아서 설치할 것이다.

# Gem download
$ bundle install

# 다운로드된 Gem 확인
$ bundle list

4. bundle package를 실행한다. 명령을 실행하면 vender/cache 폴더가 생성되고 안쪽에 필요한 Gem파일들이 있을것이다.

$ bundle package
$ ls vender/cache/

5. 이제 인터넷이 연결되지 않은 장비로 설치하자. 위에서 다운 받은 gem파일들을 복사하고, --local 옵션을 주어 gem 파일을 설치한다. ( 관리자 권한이 필요할 수 있다. )

# rails 를 다운 받았으니깐. 
$ gem install --local rails 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment