Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly set groups based on dependencies #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thatsmydoing
Copy link

Bundix incorrectly adds the default group to gems in the lock file but not in the gem file.

A Gemfile like

source 'https://rubygems.org'

gem 'rspec', group: :test

will result in rspec having the group test, but its dependencies (rspec-mocks, etc) will have both default and test.

Incidentally, this PR also fixes #39

Copy link
Author

@thatsmydoing thatsmydoing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change with how bundix writes the groups. I believe something like the fix in NixOS/nixpkgs#51884 is needed? bundlerEnv still defaults groups to just ["default"] which might break things that rely on the buggy behavior.

@@ -127,7 +127,7 @@ def build_depcache(lock)
end

lock.specs.each do |spec|
dep_cache[spec.name] ||= Dependency.new(spec.name, nil, {})
dep_cache[spec.name] ||= Dependency.new(spec.name, nil, { "group" => [] })
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop adds everything in the lockfile that isn't listed in the gemfile so technically we don't know which groups these gems are supposed to be.

If group is not specified, the constructor defaults to default which is not what we want as we want to resolve groups based on the dependency tree. So we explicitly set the group to empty which we're going to fill in later.

@@ -143,7 +143,7 @@ def build_depcache(lock)
dep_cache[name] = Dependency.new(name, lock.bundler_version, {})
end

if !((as_dep.groups - cached.groups) - [:default]).empty? or !(as_dep.platforms - cached.platforms).empty?
if !(as_dep.groups - cached.groups).empty? or !(as_dep.platforms - cached.platforms).empty?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe [:default] here is just a workaround to the wrong group set for transitive dependencies. This is also what breaks #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"default" isn't included in groups on transitive dependencies listed explicitly in other groups
1 participant