Download All Gems Dependencies

Download all gems dependencies

Thats exactly the problem I had.

After searching around a while I found a Solution who works using Bundler https://bundler.io/

Getting Gem with Dependencies:

  • Create a new Folder with a File named Gemfile in it.
  • Write a Source and the Gem you want to have the dependencys for into the File
  • Example:

    source "http://rubygems.org"

    gem 'rails', '3.2.1'

  • Open a Commandline at this Folder an Execute: bundle install
  • This should download and install all Dependencys
  • Execute the Command bundle list if you wanna see it
  • Execute the Command bundle package
  • This should create the Directory Structure vendor/cache
  • Inside the cache Directory are now all the Dependencys you need for your gem

Install Gem on Machine without internet connection:

  • Copy the cache Folder to the Machine
  • Open a Commandline inside the Cache Folder and execute gem install --local Gemname.gem
  • Example:

gem install --local rails-3.2.1.gem

How to automatically download .gem files, including dependencies, and save .gem's to one folder?

Bundler has a great way to do this: bundle package.

http://bundler.io/v1.2/bundle_package.html

The package command will put all your gems in the bundle into ./vendor/cache. You can then do whatever you want with that directory, such as copying it to another machine, or checking it into version control, or torrenting it. etc.

How to list gem dependencies for some non-intalled gem?

I know that this is a bit of a necro, but I think that you can use gem install --explain rails.

from http://guides.rubygems.org/command-reference/#gem-install

-​-explain - Rather than install the gems, indicate which would be installed

You may have to run that command from another system that CAN access the rubygems.org server, get the list of gems, pull them down, and install them on your system instead of hitting rubygems directly (till you get your network problem figured out)

How do I force Bundler to reinstall all of my gems?

bundle install --redownload

See the reference for bundle install: https://bundler.io/v2.2/man/bundle-install.1.html

or

bundle install --force

For older versions of bundler

With Ruby, does gem install use --include-dependencies... just the doc is a little outdated?

Yes, the documentation is a bit outdated.

gem install --include-dependencies option has been default for some time now.

How to install gems from Gemfile?

run the command bundle install in your shell, once you have your Gemfile created.

This command will look your Gemfile and install the relevant Gems on the indicated versions.

The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

Your can create a Gemfile just by typing bundle init in your shell

I add a Gemfile example for your reference:

source "https://rubygems.org"  # where gems will be downloaded from
ruby "2.2.3" # ruby version, change for the one you use

gem "sinatra"
gem "sinatra-flash"
gem "sinatra-partial"
gem "bcrypt"
gem "dm-validations"
gem "dm-transactions"
gem "data_mapper"
gem "dm-postgres-adapter"
gem "pg"
gem "database_cleaner"

group :test do # you can make groups for test, development, production..
gem "rspec"
gem "capybara"
gem "rspec-sinatra"
gem "cucumber"
gem "coveralls", require: false
end


Related Topics



Leave a reply



Submit