wycats / bundler

407 stars 30 forks source link

--ignore-dependencies option #143

Open takeru opened 14 years ago

takeru commented 14 years ago

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.

takeru commented 14 years ago

http://github.com/takeru/bundler/commit/79653e6af25935b92cec69fb0a5e1473bece23d0 I pushed.

woodie commented 14 years ago

this is very nice, thanks Takeru!

gbuesing commented 14 years ago

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.

gbuesing commented 14 years ago

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.)

plainprogrammer commented 11 years ago

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.

starrychloe commented 11 years ago

I agree. 'therubyrace' requires libv8, but libv8 won't compile on Windows. I would like to never install libv8.

alex88 commented 10 years ago

+1 on this

metaskills commented 7 years ago

Was using 'bundler/inline' today and felt I could use this.

adamdavis40208 commented 5 years ago

Happy 9th birthday issue #143 :)

davispuh commented 4 years ago

Jeez, how this still isn't implemented...

jishapuniyani commented 4 years ago

Please implement this!

sschuldenzucker commented 3 years ago

Jesus Christ...

ipepe commented 1 year ago

This issue is still going strong in 2023 🎉

ciembor commented 1 year ago

I need this!

tarnowsc commented 1 year ago

There is a way to remove dependencies or override the transient dependencies versions: https://github.com/tarnowsc/bundler-override

lion-man44 commented 10 months ago

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?

fmichaut-diff commented 7 months ago

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"

ipepe commented 7 months ago

@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