Setting up a Ruby gem server to use locally


Installing gems for a Ruby deployment is a pain. It will take more than hours to download the required gems and docs. To save the time and bandwidth we can have our own local gem server. To setup, a gems server follows the step by step guide.

Read more articles about Ruby:

Installing any gem:

First, install with any one of the gems.

# sudo gem install "cancan"

Then start the gem server using

Starting the Gem server:

# gem server --port 8808 --dir /var/lib/gems/1.9.1/ --bind --no-daemon

gem server = command to start the gem server
–port = In which Port we need to run the gem server
–dir = Which directory need to be used as gem repository to store and served.
–bind = Need to run in this locally.
–no-daemon = Don’t need to be run as a daemon.

If we need to run the gem server in background and while the server startup we need to add a small script

Create a script file in any name, Here i have used

# vim

Append the following gem server command in the created file

gem server --port 8808 --dir /var/lib/gems/1.9.1/ --bind --no-daemon &

Then save and exit using wq!

Start Gem server Persistently

Now to start it automatically when server was up we need to add the created file in the rc.local

# sudo vim /etc/rc.local

Append the created file location with sh to execute the command

# sh /home/sysadmin/

save and quit rc.local using wq!

Access Gem Server Dashboard

Now the gem server used to run in the, We can access the web interface using

Client side setup

Client side configuration, Create two files in below locations.

# vim ~/.gemrc
# vim /etc/gemrc

Add this Content in these above 2 files

:update_sources: true
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
gem: --no-ri --no-rdoc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri

clone any one of the project and install gems using

# bundle install

Required gems will be pulled and saved to use locally.


By setting up a local gem server we can save our bandwidth as-well save a lot of time during gems installation across all development systems. Subscribe to the newsletter and provide your feedback in below comment section.

Exit mobile version