• Stars
    star
    753
  • Rank 60,280 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A RubyGems.org cache and private gem server

Gemstash

What is Gemstash?

Gemstash is both a cache for remote servers such as https://rubygems.org, and a private gem source.

If you are using bundler across many machines that have access to a server within your control, you might want to use Gemstash.

If you produce gems that you don’t want everyone in the world to have access to, you might want to use Gemstash.

If you frequently bundle the same set of gems across multiple projects, you might want to use Gemstash.

Are you only using gems from https://rubygems.org, and don’t bundle the same gems frequently? Well, maybe you don’t need Gemstash… yet.


Gemstash is maintained by Ruby Together, a grassroots initiative committed to supporting the critical Ruby infrastructure you rely on. Contribute today as an individual or even better, as a company, and ensure that Bundler, RubyGems, Gemstash, and other shared tooling is around for years to come.

Quickstart Guide

Setup

Gemstash is designed to be quick and painless to get set up. By the end of this Quickstart Guide, you will be able to bundle stashed gems from public sources against a Gemstash server running on your machine.

Install Gemstash to get started:

$ gem install gemstash

After it is installed, starting Gemstash requires no additional steps. Simply start the Gemstash server with the gemstash command:

$ gemstash start

You may have noticed that the command finished quickly. This is because Gemstash will run the server in the background by default. The server runs on port 9292.

Bundling

With the server running, you can bundle against it. Tell Bundler that you want to use Gemstash to find gems from RubyGems.org:

$ bundle config mirror.https://rubygems.org http://localhost:9292

Now you can create a Gemfile and install gems through Gemstash:

# ./Gemfile
source "https://rubygems.org"
gem "rubywarrior"

The gems you include should be gems you don’t yet have installed, otherwise Gemstash will have nothing to stash. Now bundle:

$ bundle install --path .bundle

Your Gemstash server has fetched the gems from https://rubygems.org and cached them for you! To prove this, you can disable your Internet connection and try again. Gem files (*.gem) are cached indefinitely. Gem dependencies metadata are cached for 30 minutes, so if you bundle again before that, you can successfully bundle without an Internet connection:

$ # Disable your Internet first!
$ rm -rf Gemfile.lock .bundle
$ bundle

Falling back to rubygems.org

If you want to make sure that your bundling from https://rubygems.org still works as expected when the Gemstash server is not running, you can easily configure Bundler to fallback to https://rubygems.org.

$ bundle config mirror.https://rubygems.org.fallback_timeout true

You can also configure this fallback as a number of seconds in case the Gemstash server is simply unresponsive. This example uses a 3 second timeout:

$ bundle config mirror.https://rubygems.org.fallback_timeout 3

Stopping the Server

Once you’ve finish using your Gemstash server, you can stop it just as easily as you started it:

$ gemstash stop

You’ll also want to tell Bundler that it can go back to getting gems from RubyGems.org directly, instead of going through Gemstash:

$ bundle config --delete mirror.https://rubygems.org

Under the Hood

You might wonder where the gems are stored. After running the commands above, you will find a new directory at ~/.gemstash. This directory holds all the cached and private gems. It also has a server log, the database, and configuration for Gemstash. If you prefer, you can point to a different directory.

Gemstash uses SQLite to store details about private gems. The database will be located in ~/.gemstash, however you won’t see the database appear until you start using private gems. If you prefer, you can use a different database.

Gemstash temporarily caches things like gem dependencies in memory. Anything cached in memory will last for 30 minutes before being retrieved again. You can use memcached instead of caching in memory. Gem files are always cached permanently, so bundling with a Gemfile.lock with all gems cached will never call out to https://rubygems.org.

The server you ran is provided via Puma and Rack, however they are not customizable at this point.

Deep Dive

Deep dive into more subjects:

Reference

An anatomy of various configuration and commands:

To see what has changed in recent versions of Gemstash, see the CHANGELOG.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake to run RuboCop and the tests. While developing, you can run bin/gemstash to run Gemstash. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rubygems/gemstash. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

More Repositories

1

bundler

Manage your Ruby application's gem dependencies
Ruby
4,865
star
2

rubygems

Library packaging and distribution for Ruby.
Ruby
3,401
star
3

rubygems.org

The Ruby community's gem hosting service.
Ruby
2,209
star
4

rubygems-mirror

The `gem mirror` RubyGems command, creates local mirrors of all gems from a remote gem source.
Ruby
270
star
5

guides

An effort to provide awesome documentation for the RubyGems ecosystem.
SCSS
149
star
6

gems

Ruby wrapper for the RubyGems.org API
Ruby
124
star
7

bundler-site

The Bundler documentation website
Haml
110
star
8

rubygems-aws

DEPRECATED: Chef repo for running RubyGems.org on AWS.
Ruby
102
star
9

gemcutter

The gemcutter gem, the rails app has been moved to http://github.com/rubygems/rubygems.org
Ruby
65
star
10

rubygems-test

An attempt to replace the testing facility in rubygems via a test plugin.
Ruby
48
star
11

bundler-api

Bundler 1.1+ API
Ruby
46
star
12

rubygems-chef

The new RubyGems.org infrastructure.
Perl
41
star
13

rfcs

RubyGems + Bundler RFCs
40
star
14

rubygems-status

DEPRECATED 1/7/2016 A simple rails app to show the status of rubygems.org infrastructure
CSS
37
star
15

ruby-ssl-check

Ruby
34
star
16

rubygems.org-configs

The config files used to run rubygems.org
Ruby
30
star
17

bundler-features

Bundler feature requests and discussion
28
star
18

rubygems.github.io

the blog, for rubygems!
SCSS
20
star
19

bundler-compose

A bundler plugin to allow composing new gems into an existing bundle
Ruby
19
star
20

adoption-center

The RubyGems Adoption Center - RGSoC 2015
HTML
17
star
21

gemx

Ruby
15
star
22

bundler-graph

Ruby
14
star
23

new-index

Prototype and documentation of the new gem index format
Ruby
12
star
24

postit

A Bundler Version Manager
Ruby
11
star
25

rubygems-server

Ruby
10
star
26

rubygems-verification

Tools and data used to verify gems on rubygems.org
Ruby
10
star
27

compact_index

implements the response logic for the compact index format and to manage the versions file
Ruby
9
star
28

cacache-rb

Ruby
7
star
29

install

A simple remote eval installer with tarball unpacker (the easy way to install/update RubyGems)
Ruby
7
star
30

shipit

Ruby
6
star
31

stat-update

A very fast libev+libebb+hiredis server to update rubygems stats on the fly
C
6
star
32

meg

Quick commands to help administer and support RubyGems.org.
Shell
6
star
33

contribute

One site to show all related RubyGems ecosystem projects and help developers get involved
Ruby
6
star
34

bundlerbot

A bot that loves to help
JavaScript
5
star
35

bundler.github.io

The Bundler website, generated by https://github.com/rubygems/bundler-site
HTML
5
star
36

docs

RubyGems Manuals.
Ruby
5
star
37

search

DEPRECATED
Ruby
3
star
38

issue-triage

issue triage bot
Ruby
3
star
39

rubygems.org-backup

This is a BACKUP repo for rubygems.org before the history rewrite. Do not use. No pull requests please.
Ruby
3
star
40

rubygems.org-vendor

Submodule cache of gems to make RubyGems.org development easier!
3
star
41

rubygems-lita

A Lita chat bot for RubyGems/Bundler
Ruby
2
star
42

bundler-changelog

Ruby
1
star
43

compact_index_client

Ruby
1
star
44

apt-tools

Scripts for managing the apt repositories used for RubyGems.org machines.
Shell
1
star
45

bundler-gem

The Bundler gem creator
1
star
46

configure-rubygems-credentials

Configure rubygems.org credential environment variables for use in other GitHub Actions.
TypeScript
1
star
47

bundler-slackin

The Bundler Slack inviter
JavaScript
1
star