Skip to content

Instantly share code, notes, and snippets.

@evanphx
Last active August 8, 2016 11:44
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save evanphx/5718074 to your computer and use it in GitHub Desktop.
Save evanphx/5718074 to your computer and use it in GitHub Desktop.
Need to update a Gemfile.lock but don't want to install the gems? No problem! Run this in the same directory as your Gemfile!
#!/usr/bin/env ruby
require 'bundler'
gems = ARGV
if gems.empty?
puts "Updating all gems"
Bundler.definition(true)
else
puts "Updating gems: #{gems.join(', ')}"
lock = Bundler.read_file(Bundler.default_lockfile)
names = Bundler::LockfileParser.new(lock).specs.map{ |s| s.name }
Bundler.definition(:gems => gems, :sources => [])
end
d = Bundler.definition
puts "Resolving remotely..."
d.resolve_remotely!
d.lock(Bundler.default_lockfile)
puts "Updated lockfile!"
if Bundler.root.join("vendor/cache").exist?
puts "Downloading .gem's to update vendor/cache"
d.specs.sort_by { |s| s.full_name}.each do |s|
Bundler::Fetcher.fetch(s)
end
Bundler.load.cache
end
puts "Done! Enjoy!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment