I have bunch of gems on my computer that I want to use in a chef recipe.
I know it is possible to put them in a directory like /tmp/gems and just:
cd /tmp/gems
gem install *.gem
Is it possible to put all gems in one directory where I can install them with bundler without downloading them again?
cd /somedir/my_rails_project
bundle
I want to save bandwidth.
bundle install --local
should be what you want. From the bundle-install manpage:
--local Do not attempt to connect to rubygems.org, instead using just the gems located in vendor/cache. Note that if a more appropriate platform-specific gem exists on rubygems.org, this will bypass the normal lookup.
You can use the BUNDLE_CACHE_PATH
configuration key:
cache_path
(BUNDLE_CACHE_PATH
): The directory that bundler will place cached gems in when runningbundle package
, and that bundler will look in when installing gems. Defaults tovendor/bundle
.
Source: https://bundler.io/v1.16/bundle_config.html#LIST-OF-AVAILABLE-KEYS
In GitLab CI, I defined this value in the environment of runners: "BUNDLE_CACHE_PATH=/cache-ci/bundle"
, this directory is mounted automatically in CI runners.
Then bundle install
will install gems from the cache directory (once cache will be populated).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With