How do I handle prerelease gems on my gem server? - ruby

I am currently running a gem server for our company that stores our local in house gems. We are currently using the default rubygems server that is invoked with gem server. However whenever we fetch from this server (using bundler) we get:
Could not fetch prerelease specs from rubygems repository http://rubygems.myserver.org
The server works fine otherwise, but we would actually like to have our server support prerelease anyhow. Is anyone running a gem server successfully with prerelease? If so what server are you using and how? I cannot seem to find any documentation on this.

The solution to this is not to use gem server, but use a regular web server then execute gem generate_index. This successfully built prerelease and regular indexes.
http://docs.rubygems.org/read/chapter/18 section 4.2

Related

Changing Ruby version during deploy

I have a box with 3 Rails apps on it. I wan't to upgrade one of the apps so that it uses Ruby 2.0.0, while leaving the others running on 1.9.3-p394. I have both those Rubies installed via Rvm.
I'm trying to control the Ruby version that each app uses via it's Gemfile.
# Gemfile
ruby '2.0.0'
So, I changed the version number in the Gemfile locally, made sure it all worked, committed and now I'm trying to deploy the change to the server.
However, the cap deploy fails at this point
bundle install --gemfile [path to release Gemfile] --path [path to app bundle] --deployment --quiet --without development test
because
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
This is correct technically, my Gemfile does specify 2.0.0 and the app is currently running on 1.9.3. I'm trying to make it change versions before bundling though. How do I do that?
Your PATH is not set up correctly. You probably don't have bin: as the first entry in your path. That would lead to this error.
Even if you're not using Heroku it's worth reading this page on troubleshooting that issue: https://devcenter.heroku.com/articles/ruby-versions
Here is a link to an answer which will explain how to change your PATH on the server: Capistrano: Can I set an environment variable for the whole cap session?
If you have rvm maybe you can try to do
rvm use 2.0.0
before your bundler call.
If you're using rvm set the default to ruby 2.0.0 on your server
rvm --default use 2.0.0
Resolved the problem for me deploying to an AWS server from my mac - but I guess if I need to update my older sites I'll have to set the default back to 1.9.3 before deploying.

What is the difference between installing Rubygems "locally" and "system wide"?

I am running RHEL 6.2 on a VM (I have no control over it). I would like to use Ruby along with Mysql to do the work I need to do. But right now the server does not have the mysql gem installed. It doesn't even have ruby gems installed. So I can't simply do gem install mysql. The people maintaining the server suggested I do local install of ruby gems. Is there a benefit to this? What if the server is hosting a web application that consists of code depending on a gem? Will this effect anything?
Either in ~/.gem (local) or in /usr/lib/ruby (system). Locally installed gems are accessible by you only, system gems everyone can use.

Local gem install vs running setup.rb

What is the difference between a ruby library installed from a tarball versus through a gem install?
My machine can't connect to rubygems.org because of a university proxy, so all my installations happen locally. I have some gems that I've installed using a gem local install, and others where I've downloaded a tarball and run setup.rb or some such. In my newbie-ish state when messing around with Ruby I wasn't too phased about this inconsistency, but it bothers me now.
I assume rubygems is the preferred method, but I'd like to understand the exact pitfalls so that I can know what to watch out for when I try clean out my machine.
The most important difference is that Ruby extensions installed without the gem mechanism cannot be easily uninstalled or updated (except they provide their own mechanism for that). Automatic installation of dependencies is also largely simplified with gems.
If you are behind a proxy, you can tell gem to use that proxy as well, e.g.
gem install foo --http-proxy http://192.168.0.1:81
or define the environment variable HTTP_PROXY like
export HTTP_PROXY=http://192.168.0.1:81
Look into your browser/network settings to find the proxy address.

how to build a transparent private gem source server

My connection to default gem source server http://rubygems.org/ is slow. So I am looking for a method to build a private gem server on a machine which I have fast connection to. I have some questions after reading gems doc:
If I have multiple gem sources , what is the order which source is used when running gem install xxx?
Will any method documented in http://docs.rubygems.org/read/chapter/18 help build a transparent gem server? "Transparent" means I need this only one gem server in my gem sources, and when I request a gem from this server, it will first serve the gem from cache. If the gem is not in cache yet, the server will try to download it from http://rubygems.org/, serve and cache it.
If the answer for question 2 is "No", how can I build a transparent gem source server?
I'd suggest just installing the pre-release bundler, which is several orders of magnitude faster due to major architectural changes. It's not just your connection to rubygems that is slow; it's that painful for all of us ;) gem install bundler --pre will give you a much faster bundler.
That said, if you really want a loca gem server, try Gem in a box:
https://github.com/cwninja/geminabox
Here are a few projects that are specifically made to run a RubyGems.org mirror:
https://github.com/YorickPeterse/gem-mirror
https://github.com/rubygems/rubygems-mirror

How to deploy an RubyGem-based Server

We have built a custom socket server in ruby and packaged it as a gem. Since this is an internal project we can not simply publish it to RubyForge or GitHub. I tried to setup our own gem server but gem would not authenticate over https. Our other deployment is all for standard rails applications that use capistrano and svn for deployment.
Our current setup which is to use a rails-like deployment with capistrano. which does the following:
Check out the code from svn
Build the gem
Install the gem
Restart the server
This just seems awkward, and makes the gem packaging seem like extra work -- but outside of the deployment issue it fits really nicely as a gem.
Is there a cleaner approach?
Start
gem server #That will serve all your local installed gems.
gem install YourLocalPkg1.X.X.gem
#on YourHost
use
gem sources --add localhost:8808
gem install YourGem
on client machine
develop something
rake gem
gem install YourLocalPkg2.X.X.gem #on YourHost
use
gem update YourGem #on client machine
Maybe you have a need to use https but I don't see why in your post.
On Some Machine
* Check out the code from svn #the railspart not in the gem
* gem update YourGem # or install if not exist....
* Restart the server
You can install gems from the local filesystem.
gem install /path/to/some.gem
Shouldn't be too hard for you to script scp with that, or use an NFS mount, etc.
gem install --local path_to_gem/filename.gem will help. Or you can get a trusted certificate on your web server.
You might be able to install from the server with gem install -P NoSecurity or -P LowSecurity, but I haven't tried that.
http://www.rubygems.org/read/chapter/21

Resources