通过bundle下载安装gem包以及所需要的依赖包
以安装redmon为例子。
如果安装特定版本,用gem ‘redis‘,‘3.0.7‘指定版本号。
mkdir /offlinegems vi /offlinegems/Gemfile source ‘https://rubygems.org/‘ gem ‘redmon‘ bundle package bundle list
[root@node2 offlinegems]# bundle package Don‘t run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. Fetching source index from https://rubygems.org/ Resolving dependencies......... Using bundler 2.2.22 Fetching temple 0.8.2 Fetching daemons 1.4.0 Fetching concurrent-ruby 1.1.9 Fetching eventmachine 1.2.7 Installing eventmachine 1.2.7 with native extensions Installing temple 0.8.2 Fetching tilt 2.0.10 Installing concurrent-ruby 1.1.9 Fetching hiredis 0.6.3 Installing daemons 1.4.0 Using json 2.5.1 Fetching mixlib-cli 2.1.8 Installing tilt 2.0.10 Fetching ruby2_keywords 0.0.5 Installing ruby2_keywords 0.0.5 Fetching rack 2.2.3 Installing mixlib-cli 2.1.8 Fetching redis 4.4.0 Installing hiredis 0.6.3 with native extensions Installing redis 4.4.0 Fetching i18n 1.8.10 Installing rack 2.2.3 Fetching haml 5.2.2 Installing i18n 1.8.10 Fetching mustermann 1.1.1 Installing haml 5.2.2 Fetching rack-protection 2.1.0 Installing rack-protection 2.1.0 Installing mustermann 1.1.1 Fetching sinatra 2.1.0 Installing sinatra 2.1.0 Fetching thin 1.8.1 Installing thin 1.8.1 with native extensions Fetching redmon 0.0.13 Installing redmon 0.0.13 Bundle complete! 1 Gemfile dependency, 19 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Updating files in vendor/cache * concurrent-ruby-1.1.9.gem * daemons-1.4.0.gem * eventmachine-1.2.7.gem * temple-0.8.2.gem * tilt-2.0.10.gem * haml-5.2.2.gem * hiredis-0.6.3.gem * i18n-1.8.10.gem Fetching json 2.5.1 * json-2.5.1.gem * mixlib-cli-2.1.8.gem * ruby2_keywords-0.0.5.gem * mustermann-1.1.1.gem * rack-2.2.3.gem * rack-protection-2.1.0.gem * redis-4.4.0.gem * sinatra-2.1.0.gem * thin-1.8.1.gem * redmon-0.0.13.gem [root@node2 offlinegems]# bundle list Gems included by the bundle: * concurrent-ruby (1.1.9) * daemons (1.4.0) * eventmachine (1.2.7) * haml (5.2.2) * hiredis (0.6.3) * i18n (1.8.10) * json (2.5.1) * mixlib-cli (2.1.8) * mustermann (1.1.1) * rack (2.2.3) * rack-protection (2.1.0) * redis (4.4.0) * redmon (0.0.13) * ruby2_keywords (0.0.5) * sinatra (2.1.0) * temple (0.8.2) * thin (1.8.1) * tilt (2.0.10) Use `bundle info` to print more detailed information about a gem
bundle package会安装redmon以及需要的依赖包,并下载。
之后,就可以看到下载的gem包了:
[root@node2 cache]# pwd /offlinegems/vendor/cache [root@node2 cache]# ll total 1868 -rw-r--r-- 1 root root 358400 Aug 3 10:24 concurrent-ruby-1.1.9.gem -rw-r--r-- 1 root root 29696 Aug 3 10:24 daemons-1.4.0.gem -rw-r--r-- 1 root root 247296 Aug 3 10:24 eventmachine-1.2.7.gem -rw-r--r-- 1 root root 92160 Aug 3 10:24 haml-5.2.2.gem -rw-r--r-- 1 root root 59904 Aug 3 10:24 hiredis-0.6.3.gem -rw-r--r-- 1 root root 41984 Aug 3 10:24 i18n-1.8.10.gem -rw-r--r-- 1 root root 89088 Aug 3 10:24 json-2.5.1.gem -rw-r--r-- 1 root root 13824 Aug 3 10:24 mixlib-cli-2.1.8.gem -rw-r--r-- 1 root root 51712 Aug 3 10:24 mustermann-1.1.1.gem -rw-r--r-- 1 root root 151040 Aug 3 10:24 rack-2.2.3.gem -rw-r--r-- 1 root root 17408 Aug 3 10:24 rack-protection-2.1.0.gem -rw-r--r-- 1 root root 60416 Aug 3 10:24 redis-4.4.0.gem -rw-r--r-- 1 root root 147968 Aug 3 10:24 redmon-0.0.13.gem -rw-r--r-- 1 root root 10752 Aug 3 10:24 ruby2_keywords-0.0.5.gem -rw-r--r-- 1 root root 381952 Aug 3 10:24 sinatra-2.1.0.gem -rw-r--r-- 1 root root 39424 Aug 3 10:24 temple-0.8.2.gem -rw-r--r-- 1 root root 59904 Aug 3 10:24 thin-1.8.1.gem -rw-r--r-- 1 root root 22528 Aug 3 10:24 tilt-2.0.10.gem