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

Revert "formulae_dependents: prune build deps when linking test deps" #719

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

carlocab
Copy link
Member

This still doesn't fix the overzealous linking of formulae,
unfortunately. See Homebrew/homebrew-core#89621.

This reverts commit 85aaf19.

This still doesn't fix the overzealous linking of formulae,
unfortunately. See Homebrew/homebrew-core#89621.

This reverts commit 85aaf19.
@carlocab
Copy link
Member Author

Sorry @FnControlOption, this didn't work. Thanks anyway!

@carlocab
Copy link
Member Author

Btw, @MikeMcQuaid, I'm not able to merge this (merge button is greyed out), but this (and #717) should be ready to go.

@Bo98
Copy link
Member

Bo98 commented Nov 18, 2021

This probably would have worked if we did:

dependent.recursive_dependencies do |dep_dependent, dependency|
  Dependency.prune if dependency.build? && !dependency.test?
  Dependency.prune if dependency.test? && dep_dependent != dependent

@MikeMcQuaid
Copy link
Member

@carlocab should be fixed now, can you try again?

@carlocab
Copy link
Member Author

Yep, merge button is green. Thanks!

This probably would have worked if we did:

dependent.recursive_dependencies do |dep_dependent, dependency|
  Dependency.prune if dependency.build? && !dependency.test?
  Dependency.prune if dependency.test? && dep_dependent != dependent

While this does fix the linked CI error, this does not seem to fix the original error we wanted to fix. Our test cases are mathblibtools and phplint. We need: coreutils to be linked when dependent is mathlibtools, and we need httpd to be not linked when dependent is phplint. We get the latter but not the former:

# linked.rb
require 'formula'

def puts_linked(dependent)
  dependent.recursive_dependencies do |dep_dependent, dependency|
    Dependency.prune if dependency.build? && !dependency.test?
    Dependency.prune if dependency.test? && dep_dependent != dependency

    dependency_f = dependency.to_formula
    Dependency.skip if dependency_f.keg_only?
    puts dependency_f.full_name
  end
end

puts ARGV[0]
puts_linked(Formula[ARGV[0]])

Here's what we get:

❯ brew ruby linked.rb "mathlibtools" | rg -q 'coreutils'; echo $?
1
❯ brew ruby linked.rb "phplint" | rg -q 'httpd'; echo $?
1

@carlocab carlocab merged commit e604a50 into Homebrew:master Nov 18, 2021
@carlocab carlocab deleted the revert-prune branch November 18, 2021 15:00
@Bo98
Copy link
Member

Bo98 commented Nov 18, 2021

Your != condition is wrong. It should be dep_dependent != dependent.

@carlocab
Copy link
Member Author

carlocab commented Nov 18, 2021

And here I thought I double-checked that... and yes, it works:

❯ brew ruby linked.rb "mathlibtools"
mathlibtools
lean
coreutils
gmp
gmp
jemalloc
gdbm
mpdecimal
ca-certificates
xz
six

This seems to have a bunch of duplicates though which we don't have by just iterating over recursive_dependencies. It's possible (likely?) this is more correct though.

❯ brew ruby linked.rb "phplint" | wc -l
60
❯ brew ruby linked.rb "phplint" | sort | uniq | wc -l
36

@Bo98
Copy link
Member

Bo98 commented Nov 18, 2021

This seems to have a bunch of duplicates

You should take the return value and print that rather than treat the block like .each. The block passed here is a filter and should do nothing more than that.

@carlocab
Copy link
Member Author

So we'd need to move the brew link step outside the block too. Ok, let's see...

@carlocab
Copy link
Member Author

carlocab commented Nov 18, 2021

Edit: Ah, never mind. Same typo.

Not sure what I'm doing wrong here:

# linked.rb
require 'formula'

def linked(dependent)
  dependent.recursive_dependencies do |dep_dependent, dependency|
    Dependency.prune if dependency.build? && !dependency.test?
    Dependency.prune if dependency.test? && dep_dependent != dependency

    dependency_f = dependency.to_formula
    Dependency.skip if dependency_f.keg_only?
  end
end

puts linked(Formula[ARGV[0]]).map(&:to_s)
❯ brew ruby linked.rb "mathlibtools"
gdbm
mpdecimal
ca-certificates
xz
six

No more coreutils.

carlocab added a commit to carlocab/homebrew-test-bot that referenced this pull request Nov 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants