specify gem server name outside of Gemfile?

93 views
Skip to first unread message

deet

unread,
Apr 3, 2013, 11:52:36 AM4/3/13
to ruby-bundler
Folks.

I'm using Bundler version 1.3.4. I am looking for a solution to
specifying the location of the gem server outside of the Gemfile.
For my current use case a developer will create a Gemfile/Gemfile.lock
which contain a line like this

source 'https://rubygems.org'

These files then get committed to source control and then distributed
to the various servers using puppet (a configuration management
tool). When the files get published to the servers it triggers a
'bundle install' against the particular Gemfile/Gemfile.lock. The
problem is these servers don't actually have access to 'https://
rubygems.org' as we have an internal gem server.

I tried creating an /etc/gemrc and ~/.gemrc file which contains the
location of our internal gem server
---
:sources:
- http://gems.my.domain.net

But this file does not seem so get used by 'bundle install'.

So any tips on how I can solve this problem to ensure the same Gemfile/
Gemfile.lock that is used on a workstation with internet access will
work on a server that does not have internet access.

Ideally some tip on how to specify the actual gem server in an
location that is used by bundler which is outside the common Gemfile/
Gemfile.lock.

TIA. Derek.

André Arko

unread,
Apr 20, 2013, 1:25:00 AM4/20/13
to ruby-b...@googlegroups.com
Installing gems from two completely different servers in development and production is not a feature that Bundler currently provides. The idea behind a Gemfile.lock is that the gems (and the servers they came from) should be the same in development and production, so that you can at least eliminate that as a source of possible issues.

Since you can use arbitrary ruby code inside a Gemfile, you might be able to do something like this in your Gemfile:

YAML.load_file("sources.yml").each do |url|
source url
end

However, the source URL will probably still be written into the Gemfile.lock. You'll likely have to run `bundle install` from one of the internal servers to get a Gemfile.lock that you can use to deploy to the other internal machines.
> --
> You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.
> To post to this group, send email to ruby-b...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ruby-bundler?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages