Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
Last active December 12, 2015 00:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevenhaddox/4686590 to your computer and use it in GitHub Desktop.
Save stevenhaddox/4686590 to your computer and use it in GitHub Desktop.
Is it safe to use $ bundle package and subsequently $ bundle install --local for your deploy while waiting for the new rubygems.org?

Can you bypass RubyGems.org and still deploy?

If you can run the following command and get the following result:

$ bundle check                                                                             
The Gemfile's dependencies are satisfied

CONGRATULATIONS!

You can run the bundle package command and still deploy your project without needing to touch RubyGems.org (perhaps stick in 127.0.0.1 in your hosts file if you're still concerned):

$ bundle package                                                                           
Using rake (0.9.2.2)                                                                                                  
Using addressable (2.3.2)                                                                                             
Using ffi (1.2.0)                                                                                                     
Using childprocess (0.3.6)                                                                                            
Using builder (3.1.4)                                                                                                 
Using diff-lcs (1.1.3)                                                                                                
Using json (1.7.6)   
Using gherkin (2.11.5)                                                                                                
Using cucumber (1.2.1)                                                                                                
Using rspec-expectations (2.12.0)                                                                                     
Using aruba (0.5.1)                                                                                                   
Using awesome_print (1.1.0)                                                                                           
Using bundler (1.2.3)                                                                                                 
Using mime-types (1.19)                                                                                               
Using nokogiri (1.5.5)                                                                                                
Using rack (1.4.1)                                                                                                    
Using rack-test (0.6.2)                                                                                               
Using websocket (1.0.4)                                                                                               
Using libwebsocket (0.1.7.1)                                                                                          
Using multi_json (1.4.0)                                                                                              
Using rubyzip (0.9.9)                                                                                                 
Using selenium-webdriver (2.26.0)                                                                                     
Using xpath (1.0.0)                                                                                                   
Using capybara (2.0.1)                                                                                                
Using colorize (0.5.8)                                                                                                
Using crack (0.3.1)                                                                                                   
Using gli (2.5.4)                                                                                                     
Using gem_grepper (0.0.1) from source at .                                                                            
Using gherkin-ruby (0.2.1)                                                                                            
Using rdoc (3.12)                                                                                                     
Using rspec-core (2.12.1)                                                                                             
Using rspec-mocks (2.12.0)                                                                                            
Using rspec (2.12.0)                                                                                                  
Using spinach (0.6.0)                                                                                                 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.                         
Updating files in vendor/cache                                                                                        
  * rake-0.9.2.2.gem                                                                                                  
  * addressable-2.3.2.gem                                                                                             
  * ffi-1.2.0.gem                                                                                                     
  * childprocess-0.3.6.gem                                                                                            
  * builder-3.1.4.gem                                                                                                 
  * diff-lcs-1.1.3.gem                                                                                                
  * json-1.7.6.gem                                                                                                    
  * gherkin-2.11.5.gem                                                                                                
  * cucumber-1.2.1.gem                                                                                                
  * rspec-expectations-2.12.0.gem                                                                                     
  * aruba-0.5.1.gem                                                                                                   
  * awesome_print-1.1.0.gem                                                                                           
  * mime-types-1.19.gem                                                                                               
  * nokogiri-1.5.5.gem                                                                                                
  * rack-1.4.1.gem                                                                                                    
  * rack-test-0.6.2.gem                                                                                               
  * websocket-1.0.4.gem                                                                                               
  * libwebsocket-0.1.7.1.gem                                                                                          
  * multi_json-1.4.0.gem                                                                                              
  * rubyzip-0.9.9.gem                                                                                                 
  * selenium-webdriver-2.26.0.gem                                                                                     
  * xpath-1.0.0.gem                                                                                                   
  * capybara-2.0.1.gem                                                                                                
  * colorize-0.5.8.gem                                                                                                
  * crack-0.3.1.gem                                                                                                   
  * gli-2.5.4.gem                                                                                                     
  * gherkin-ruby-0.2.1.gem                                                                                            
  * rdoc-3.12.gem                                                                                                     
  * rspec-core-2.12.1.gem                                                                                             
  * rspec-mocks-2.12.0.gem                                                                                            
  * rspec-2.12.0.gem                                                                                                  
  * spinach-0.6.0.gem

Deploying

After that you can modify your deploy scripts to use Bundler's local install which bypasses RubyGems.org completely:

$ bundle install --local
#OR for production deployments:
$ bundle install --local --without development test

The default Bundler's deployment hook runs the following (thanks to @indirect for the refresher):

$ bundle install --path vendor/bundle --without development test --frozen

Because of this you're manually telling it not to look at rubygems.org and should be safe to go with that as well. I'm fairly certain the above command is the same as:

$ bundle install --deployment

Hopefully all of the above should be safe for you to use as methods to deploy in your scripts until rubygems.org is fully available again (which seems like it'll be sooner rather than later).

What if you don't have all teh gemz?

If bundle check isn't fully successful you can try seeing if you have the gems locally by running the following on your develpment machine:

# Find all gems in your home folder (faster)
$ find ~ -name *.gem
# Find a specific gem in your home folder if you know part of the name (cleaner results)
$ find ~ -name <partial_gem_name>*.gem

# The same commands can be done for your whole system with:
$ find / -name *.gem
$ find / -name <partial_gem_name>*.gem

# Once you find the gem's location, install it from the root of your app:
$ cd <your_app>
# The -l flag restricts all operations to the local system and bypasses rubygems.org:
$ gem install -l <path_to_your_gem>/<gem_name>-<gem_version>.gem

Once you've got all the gems accessible and made bundle check happy you should be able to safely run bundle package and update your deploy scripts as described above.

@indirect
Copy link

Check out cap -e bundle:install for the docs on how to customize capistrano's bundling task. To simply add --local to the flags passed to bundle install, insert this line into deploy.rb, after the line require 'bundler/capistrano':

set :bundle_flags, "--deployment --quiet --local"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment