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

cpanm detects and does not try to double-install modules that depend on themselves #503

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

tomeon
Copy link

@tomeon tomeon commented Jun 7, 2016

Some modules list themselves as dependencies (looking at you, Bundle::CPAN). In combination with cpanm's tracking of $self->{seen}{$module}, this causes cpanm to mark such a module as having an unsatisfied dependency -- namely, itself. This PR implements a fix that filters out a module from the list of its dependencies and issues a warning message to that effect.

@tomeon tomeon force-pushed the prereq_cycle branch 3 times, most recently from b67ecf6 to 09738f3 Compare April 23, 2024 02:34
my $module_name = $self->find_module_name($configure_state) || $dist->{meta}{name};
$module_name =~ s/-/::/g;

my @all_deps = $self->find_prereqs($dist);
my @deps = grep { $_->module ne $module_name } @all_deps;
Copy link

Choose a reason for hiding this comment

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

Will depending on SelfDep::SubPackage from the same dist trick this check?

Copy link
Author

Choose a reason for hiding this comment

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

Indeed it would; well-spotted. I was concerned about this as well, but thought it better to catch at least some cases rather than none.

I've pushed some changes to address the sub-package case: now, the code uses Module::Metadata->package_versions_from_directory to enumerate all packages in $dist->{dir}. This should catch the SelfDep::SubPackage case, but I'm worried that the logic is now overbroad and catches things like modules that aren't exposed for public consumption (e.g. test-suite-only stuff).

Copy link
Author

Choose a reason for hiding this comment

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

I'm worried that the logic is now overbroad and catches things like modules that aren't exposed for public consumption (e.g. test-suite-only stuff).

On reflection, this probably isn't a big deal.

Copy link

Choose a reason for hiding this comment

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

Yep. You can hide from the metacpan indexer with:

package # hide from indexer
  MyApp::Secret;

I assume the same trick works elsewhere

@tomeon
Copy link
Author

tomeon commented Apr 29, 2024

Some tests are failing, but they're also failing in devel.

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.

2 participants