简体   繁体   中英

How to install the git head of a gem through Rubygems.org?

Currently, Rails' Github master is on version 6.1.0-alpha. However, this version is not available through Rubygems.

> gem search ^rails$ --pre

*** REMOTE GEMS ***

rails (6.0.3.rc1, 6.0.2.rc2, 6.0.2.rc1, 6.0.1.rc1, 6.0.0.rc2, 6.0.0.rc1, 6.0.0.beta3, .......)

Is there a way to force a gem to be installed with the latest commit through Rubygems.org without using Bundler? Something like Homebrew's devel or the example below would be ideal:

gem install rails --head

When I need to use a head of gem, I just use through Github source like this.

gem 'rails', github: 'rails/rails', branch: 'master'

Since this version is not released on Rubygems yet, I don't know is there a way to use it through RubyGems.

Be aware that installation by Github took long even with fast internet connection.

Is there a way to force a gem to be installed with the latest commit through Rubygems.org without using Bundler?

The short answer is no, you cannot force-install an unpublished gem through RubyGems.org because RubyGems is a repository for published gems. If the repository owner has pushed a version of the gem to RubyGems you can find and install it. If they haven't, you can't.

If you want to use pre-published code from a repository, use the Bundler method outlined in Semih's answer:

gem 'rails', github: 'rails/rails', branch: 'master'

Per the RubyGems site documentation:

Installing a gem directly from a git repository is a feature of Bundler, not a feature of RubyGems. Gems installed this way will not show up when you run gem list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM