Setting up a Ruby gem server to use locally
Read Time:2 Minute, 12 Second

Setting up a Ruby gem server to use locally

0 0
0 0

Introduction

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 192.168.1.51 --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 gem.sh

# vim gem.sh

Append the following gem server command in the created file

gem server --port 8808 --dir /var/lib/gems/1.9.1/ --bind 192.168.1.51 --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/gem.sh

save and quit rc.local using wq!

Access Gem Server Dashboard

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

http://192.168.1.51:8808/

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
:sources:
- http://192.168.1.51:8808/
- http://gems.rubyforge.org/
: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.

Conclusion:

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.

Setting up a Ruby gem server to use locally 1

About Post Author

Babin Lonston

Overall 14+ Years of experience in the IT field, currently working as a Senior Linux administration with Virtualization & Cloud. Being numismatist for a long time.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published.

Previous post resolvconf: Error: /etc/resolv.conf isn’t a symlink, not doing anything
Next post Install and configure Logwatch in Ubuntu-Server

Subscribe

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

We promise not to spam you, and we don't usually send more than one email a week.

You have Successfully Subscribed!