|Total downloads||14+ billion|
Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Ruby -ropenssl -e 'p OpenSSL::OPENSSLVERSION' 'OpenSSL 0.9.8y 5 Feb 2013' openssl sclient -showcerts -connect rubygems.org:https CONNECTED(00000003) depth=1 C = US, O = 'GeoTrust, Inc.' , CN = RapidSSL CA verify error:num=20:unable to get local issuer certificate verify return:0 - Certificate chain 0 s:/serialNumber. Hi, I’m running into problems when trying to install Instiki on my Mac (OS X Lion). Ruby version seems to be 1.8.7. A previous version of Instiki (I think it was 0.19.4) worked fine. This problem appeared when I re-installed the developer tools from the App Store, but this might as well be a coincidence.
- Gem update -system is disabled on Debian. RubyGems can be updated using the official Debian repositories. This is due to using apt-get install rubygems. We recommend that you uninstall RubyGems via Aptitude and install it from source. Further instructions are here for doing so. Rails requires RubyGems = 1.3.1 (you have 1.2.0).
- If you try rails new foo to build a new Rails application with RubyGems 1.8.23 and Ruby 1.9.3-p194 you'll get an error because RubyGems now verifies SSL certificates and Bundler tries to connect with when you build a new Rails app and is wrongly configured for SSL connections.
RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a 'gem'), a tool designed to easily manage the installation of gems, and a server for distributing them. It was created by Chad Fowler, Jim Weirich, David Alan Black, Paul Brannan and Richard Kilmer during RubyConf 2004.
The interface for RubyGems is a command-line tool called gem which can install and manage libraries (the gems). RubyGems integrates with Ruby run-time loader to help find and load installed gems from standardized library folders. Though it is possible to use a private RubyGems repository, the public repository is most commonly used for gem management.
The public repository helps users find gems, resolve dependencies and install them. RubyGems is bundled with the standard Ruby package as of Ruby 1.9.
Development on RubyGems started in November 2003 and was released to the public on March 14, 2004, or Pi Day 2004. In 2010, the default public repository for gems moved from http://gems.rubyforge.org to http://rubygems.org, which is still in use. Also, RubyGems development was moved to GitHub in 2010. Though RubyGems has existed since Ruby 1.8, it was not a part of the standard Ruby distribution until Ruby 1.9.
Previously, compatibility with RubyGems and Ruby varied. Many versions of RubyGems are almost fully incompatible with many versions of Ruby and some versions had key features unusable. For example, Ruby 1.9 came with RubyGems 1.3.7 in its standard distribution, but RubyGems 1.4.x was not compatible with Ruby 1.9. This meant that updating RubyGems on Ruby 1.9 was not possible until RubyGems 1.5.0 was released in 2011, two years after the first stable release of Ruby 1.9. These compatibility issues led to a rapid development of RubyGems, switching to a 4–6 week release schedule. This is reflected in there being 38 releases from 2004 to 2010 and 117 releases from 2011 to 2016. 45 versions were released in 2013, which is the highest number of releases in a year for RubyGems.
Structure of a gem
Every gem contains a name, version and platform. Gems work only on ruby designed for a particular platform based on CPU architecture and operating-system type and version.
Each gem consists of:
- Gem specification (Gemspec)
The code organization follows the following structure for a gem called gem_name:
- The lib directory contains the code for the gem.
- The test (or spec) directory is used for testing.
- Rakefile is used by Rake to automate tests and to generate code.
- README includes the documentation, RDOC, for most gems.
- Gem specification (gemspec) contains information about the author of the gem, the time of creation and the purpose the gem serves.
Working with gems
Gems are packages similar to Ebuilds. They contain package information along with files to install.
Gems are usually built from '.gemspec' files, which are YAML files containing information on gems. However, Ruby code may also build gems directly. Such a practice is usually used with Rake.
gem command is used to build, upload, download, and install gem packages.
RubyGems is very similar to apt-get, portage, yum and npm in functionality.
Listing installed gems:
Listing available gems, e.g.:
Create RDoc documentation for all gems:
Adding a trusted certificate:
Download but do not install a gem:
Search available gems, e.g.:
gem package building
The gem command may also be used to build and maintain
.gem from a
Since ruby gems run their own code in an application it may lead to various security issues due to installation of malicious gems. The creator of malicious gems may be able to compromise the user system or server.
A number of methods have been developed to counter the security threat:
- Cryptographic signing of gems since RubyGems version 0.8.11. The gem cert and gem install commands are used for this purpose.
- New signing models such as X509 and OpenPGP have been proposed and are actively being discussed among Ruby experts.
- ^'Release 3.1.4'. 25 June 2020. Retrieved 26 June 2020.
- ^'174 Rubygems with Eric Hodel'.
- ^'RubyGems Command Reference'. guides.rubygems.org. Retrieved 2016-09-18.
- ^'Ruby 1.9.1 changelog'.
- ^ ab'Version history of RubyGems'. GitHub. Retrieved 2016-09-18.
- ^'Ruby 1.9.1 released'. www.ruby-lang.org. Retrieved 2016-09-18.
- ^'What is a gem? - RubyGems.org'. guides.rubygems.org. Retrieved 2016-09-18.
- ^'gem cert'. guides.rubygems.org. Retrieved 2016-09-23.
- ^'Security - RubyGems Guides'. guides.rubygems.org. Retrieved 2016-09-23.
Ruby and RubyGems
Ruby and RubyGems are usually installed by default on Macs. Open your Terminal and type
which ruby and
which gem to confirm that you have Ruby and Rubygems. You should get a response indicating the location of Ruby and Rubygems.
If you get responses that look like this:
Great! Skip down to the Bundler section.
However, if your location is something like
/Users/MacBookPro/.rvm/rubies/ruby-2.2.1/bin/gem, which points to your system location of Rubygems, you will likely run into permissions errors when trying to get a gem. A sample permissions error (triggered when you try to install the jekyll gem such as
gem install jekyll) might look like this for Rubygems:
Instead of changing the write permissions on your operating system’s version of Ruby and Rubygems (which could pose security issues), you can install another instance of Ruby (one that is writable) to get around this.
Homebrew is a package manager for the Mac, and you can use it to install an alternative instance of Ruby code. To install Homebrew, run this command:
If you already had Homebrew installed on your computer, be sure to update it:
Install Ruby through Homebrew
Now use Homebrew to install Ruby:
Log out of terminal, and then then log back in.
When you type
which ruby and
which gem, you should get responses like this:
Now Ruby and Rubygems are installed under your username, so these directories are writeable.
Rubygems Issues For Mac Catalina
Note that if you don’t see these paths, try restarting your computer or try installing rbenv, which is a Ruby version management tool. If you still have issues getting a writeable version of Ruby, you need to resolve them before installing Bundler.
See Full List On Bundler.io
Install the Jekyll gem
At this point you should have a writeable version of Ruby and Rubygem on your machine.
gem to install Jekyll:
You can now use Jekyll to create new Jekyll sites following the quick-start instructions on Jekyllrb.com.
Installing dependencies through Bundler
Some Jekyll themes will require certain Ruby gem dependencies. These dependencies are stored in something called a Gemfile, which is packaged with the Jekyll theme. You can install these dependencies through Bundler. (Although you don’t need to install Bundler for this Documentation theme, it’s a good idea to do so.)
Bundler is a package manager for RubyGems. You can use it to get all the gems (or Ruby plugins) that you need for your Jekyll project.
You install Bundler by using the gem command with RubyGems:
If you’re prompted to switch to superuser mode (
sudo) to get the correct permissions to install Bundler in that directory, avoid doing this. All other applications that need to use Bundler will likely not have the needed permissions to run.
Bundler goes out and retreives all the gems that are specified in a Jekyll project’s Gemfile. If you have a gem that depends on other gems to work, Bundler will go out and retrieve all of the dependencies as well. (To learn more about Bundler, see About Ruby Gems.
The vanilla Jekyll site you create through
jekyll new my-awesome-site doesn’t have a Gemfile, but many other themes (including the Documentation theme for Jekyll) do have a Gemfile.
Serve the Jekyll Documentation theme
Rubygems Issues For Mac Operating System
- Browse to the directory where you downloaded the Documentation theme for Jekyll.
- Go to the preview address in the browser. (Make sure you include the
/at the end.)