Making your own Gems Repository
I am so happy to write my first Tech Blog! Yay!
So, I will explain to you, how you can make your own gems repository for private use within a small organization. This article assumes that you have a debian based client-server architecture. This article also assumes that you have a way of reaching the server through your machine. You need the following to make your own gems repository
1. A web server running (In my case apache2) on the server machine from now referred to as S
2. Rubygems installed on S
Now follow the steps.
Server Side : (The actual gem repository)
1. Install builder using the following command
sudo gem install builder
2. Say, /var/www is the root directory for your web server (It can be anything as long as it is properly listed in the config file which in our case is /etc/apache2/sites-available/default)
3. Issue the following commands
cd /var/www
mkdir gems (If root privileges are required then a sudo mkdir gems)
4. Then copy all the gems into this directory with the following command
cp -r /usr/lib/ruby/gems/1.8 /var/www/gems
5. Your gems directory may be at a different location, you can look it up using the folowing command
ruby -e 'puts $:'
6. Once you have copied all the gems, issue the following command
gem generate_index -d /var/www
After running this command you can issue the following command to check your local gems,
gem query --local
This command will list all the local gems that will be present in the repository.
7. After running this command, your yaml indexes would be generated. Now you can run the following command to start your gem server
sudo gem server http://hostname.domain.com:8808
where hostname.domain.com is the name of your computer followed by the port number 8808.
8. This should start your gem server!!!!!
A note : You should repeat this process on the server each time you install a new gem if you want this gem to be in your repository for remote install in your clients.
Client Side : (Where all the installtions will be performed using the gem install command)
1. Add the repository to your gem sources list using the following command
sudo gem sources -a http://hostname.domain.com:8808
This will add the gem repository to your gem sources.
Testing on the client
To test whether your system is working, do the following.
1. Remove rubyforge source from the sources list using the following command
sudo gem sources -r http://gems.rubyforge.com
2. List the sources using the following command
sudo gem sources
You should see only your own gem repository listed. If you have others, remove them as well, they can be added easily again using the 'gem sources -a http://hostname.domain.com' command
3. And now try to install any gem that is not installed on your client but is available in your gem repository. For example if you do not have "god" installed on your client but have it in your gem repository, issue the command
sudo gem install god
4. If your installation succeeds, you can rejoice and shout woohooo (this is what I did when it actually happened!!!)
I hope this is helpful to beginners like me. I also hope I have the jargon right as I am writing a tech blog for the first time. More tech blogs to follow! If you have any question, leave me a comment and I will try to answer them.
Barakhaa
So, I will explain to you, how you can make your own gems repository for private use within a small organization. This article assumes that you have a debian based client-server architecture. This article also assumes that you have a way of reaching the server through your machine. You need the following to make your own gems repository
1. A web server running (In my case apache2) on the server machine from now referred to as S
2. Rubygems installed on S
Now follow the steps.
Server Side : (The actual gem repository)
1. Install builder using the following command
sudo gem install builder
2. Say, /var/www is the root directory for your web server (It can be anything as long as it is properly listed in the config file which in our case is /etc/apache2/sites-available/default)
3. Issue the following commands
cd /var/www
mkdir gems (If root privileges are required then a sudo mkdir gems)
4. Then copy all the gems into this directory with the following command
cp -r /usr/lib/ruby/gems/1.8 /var/www/gems
5. Your gems directory may be at a different location, you can look it up using the folowing command
ruby -e 'puts $:'
6. Once you have copied all the gems, issue the following command
gem generate_index -d /var/www
After running this command you can issue the following command to check your local gems,
gem query --local
This command will list all the local gems that will be present in the repository.
7. After running this command, your yaml indexes would be generated. Now you can run the following command to start your gem server
sudo gem server http://hostname.domain.com:8808
where hostname.domain.com is the name of your computer followed by the port number 8808.
8. This should start your gem server!!!!!
A note : You should repeat this process on the server each time you install a new gem if you want this gem to be in your repository for remote install in your clients.
Client Side : (Where all the installtions will be performed using the gem install command)
1. Add the repository to your gem sources list using the following command
sudo gem sources -a http://hostname.domain.com:8808
This will add the gem repository to your gem sources.
Testing on the client
To test whether your system is working, do the following.
1. Remove rubyforge source from the sources list using the following command
sudo gem sources -r http://gems.rubyforge.com
2. List the sources using the following command
sudo gem sources
You should see only your own gem repository listed. If you have others, remove them as well, they can be added easily again using the 'gem sources -a http://hostname.domain.com' command
3. And now try to install any gem that is not installed on your client but is available in your gem repository. For example if you do not have "god" installed on your client but have it in your gem repository, issue the command
sudo gem install god
4. If your installation succeeds, you can rejoice and shout woohooo (this is what I did when it actually happened!!!)
I hope this is helpful to beginners like me. I also hope I have the jargon right as I am writing a tech blog for the first time. More tech blogs to follow! If you have any question, leave me a comment and I will try to answer them.
Barakhaa
