Open takeru opened 14 years ago
this is very nice, thanks Takeru!
I have yet to test out this patch, but I could definitely use this feature -- I've forked a gem and namespaced it under my own namespace (e.g., "gbuesing-foolib"); I run into issues when other libraries I'm bundling have a dependency on "foolib" -- bundler installs both "foolib" and "gbuesing-foolib". "foolib" also has dependencies that I've removed from my fork, so those are bundled as well.
Ideally, you'd be able to pass in specifically which dependencies you'd like to avoid, like:
gem 'somelib', "0.1.0", :ignore_dependencies=> ['foolib', 'barlib']
Also, Rubygems calls this feature "--skip-dependencies" on the command line, so it might make sense to use this wording.
Just to throw this idea out there -- another way to tackle this would be, a "skip_gem" command, to indicate that you never want this gem installed, no matter who is depending on it, like:
skip_gem "extlib"
... this will save you from having to track down all the dependencies that are trying to require Extlib (and just so that their library can use Object#blank? or some other feature that's easily fulfilled by another library.)
The idea of a skip_gem
option would be really useful in cases where gem authors include gems in their runtime dependencies that are really just development dependencies. Especially when they are slow to accept pull requests fixing such issues.
I agree. 'therubyrace' requires libv8, but libv8 won't compile on Windows. I would like to never install libv8.
+1 on this
Was using 'bundler/inline' today and felt I could use this.
Happy 9th birthday issue #143 :)
Jeez, how this still isn't implemented...
Please implement this!
Jesus Christ...
This issue is still going strong in 2023 🎉
I need this!
There is a way to remove dependencies or override the transient dependencies versions: https://github.com/tarnowsc/bundler-override
Actually, I think this is a nice idea.
Because we will make micro-services in these days, despite using rails.
And normally I don't need some gems, especially actionview
, actiontext
, actioncable
and also rails-dom-testing
(I don't know why but this gem takes long time in my docker) in my case.
Is there no opportunity implementing this one?
We need this, but instead of a boolean ignoring all dependencies, it should be an array of dependencies to ignore, so we don't have to manually require all gems we do require
But we need a way to blacklist unused dependencies. Most common use-case is Rails requiring ActionMailer by default, when most app don't need it. It sounds like this could be easily added to bundler.
Yes, if used improperly it could prevent the application to boot, but that's the developper's responsibility to use this option properly, and to be expected from such an option. It basically tells bundler "I know what I'm doing, don't include this"
@fmichaut-diff I have recently achieved similiar solution using a simple custom ruby script:
#!/usr/bin/env ruby
# this script parses Gemfile and Gemfile.lock, finds ARGV gem groups in Gemfile,
# and outputs the list of gems that are in ARGV groups and are in Gemfile.lock
# example usage:
# ./one-bundle-install lint
require "bundler" # Set up gems listed in the Gemfile.
groups = ARGV.map(&:to_sym)
puts "Installing gems from groups: #{groups.join(', ')}"
names = Bundler.definition.dependencies.select { |d| (d.groups & groups).any? }.map(&:name)
puts "Found gem names: #{names.join(', ')}"
gems = Bundler.definition.resolve.select { |s| names.include?(s.name) }
puts "Resolving versions: #{gems.map { |g| "#{g.name} (#{g.version})" }.join(', ')}"
puts "Installing gems..."
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
ruby RUBY_VERSION
gems.each do |g|
gem g.name, g.version.to_s
end
end
puts "Done!"
And I add groups like:
group :lint, :development do
gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
end
To my Gemfile
and this way I can install rubocop on CI without installing all dependencies using ./one-bundle-install lint
Like this:
gem 'rails', "2.3.5", :ignore_dependencies=>true gem 'actionpack', "2.3.5" gem 'activesupport', "2.3.5"
I don't need activerecord, activeresource, actionmailer.