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

Slicer fails when missing dependency #610

Closed
vaclavHala opened this issue Feb 1, 2022 · 8 comments
Closed

Slicer fails when missing dependency #610

vaclavHala opened this issue Feb 1, 2022 · 8 comments
Labels
Milestone

Comments

@vaclavHala
Copy link

Hi, I've encountered the following problem and I'm not sure if its a bug or I just misunderstood the docs I found.

I have tycho configured to use target definition file. In the target file there are multiple locations like this

<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
            <repository location="some_repo_1"/>

            <unit id="some_unit_1" version="1"/>
</location>

<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
            <repository location="some_repo_2"/>

            <unit id="some_unit_2" version="1"/>
</location>

...

Say some_unit_2 depends on some_unit_1 which is only available in some_repo_1. When I try to run a build using this target I get following error

[ERROR] Cannot resolve target definition:
[ERROR]   Problems resolving provisioning plan.:
[ERROR]      Unable to satisfy dependency from some_unit_2 to org.eclipse.equinox.p2.iu; some_unit_1 [1,1]

Digging into the code I think I found the culprit.

First because I use "slicer" mode

// InstallableUnitResolver
    public IQueryResult<IInstallableUnit> resolve(IQueryable<IInstallableUnit> allUnits) throws ResolverException {
        UnitCollector collector = new UnitCollector();
        if (haveContent()) {
            if (includeMode == IncludeMode.PLANNER) {
                //resolve as one bulk
                ...
            } else {
                //resolve every locations as its own
                ...
                // my build goes through here, this I think explains why one location can not see the other
            }
        }
        return collector;
    }

so now org.eclipse.equinox.internal.p2.director.Slicer is used and it runs into this

// Slicer
	private void expandRequirement(IInstallableUnit iu, IRequirement req) {
		if (req.getMax() == 0)
			return;
		IQueryResult<IInstallableUnit> matches = possibilites.query(QueryUtil.createMatchQuery(req.getMatches()), null);
		int validMatches = 0;
		...
		if (validMatches == 0) {
			if (req.getMin() == 0) {
				if (DEBUG)
					System.out.println("No IU found to satisfy optional dependency of " + iu + " on req " + req); //$NON-NLS-1$//$NON-NLS-2$
			} else {
				result.add(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req)));
                                // WARNING is added to the result, it seems strange to me to emit Planner message from a Slicer but ok
			}
		}
	}

and when this result is evaluated it is treated as failure

// AbstractSlicerResolutionStrategy
protected final IQueryable<IInstallableUnit> slice(Map<String, String> properties, IProgressMonitor monitor) throws ResolverException {
        ...
        Slicer slicer = newSlicer(new QueryableCollection(availableIUs), properties);
        IQueryable<IInstallableUnit> slice = slicer.slice(seedIUs.toArray(EMPTY_IU_ARRAY), monitor);
        MultiStatus slicerStatus = slicer.getStatus();
        if (slice == null || isSlicerError(slicerStatus)) {
            throw new ResolverException(StatusTool.toLogMessage(slicerStatus), properties.toString(),
                    StatusTool.findException(slicerStatus));
        }

// SlicerResolutionStrategy
    @Override
    protected boolean isSlicerError(MultiStatus slicerStatus) {
        // this I believe is the root cause - because Slicer is from eclipse we can not make that not emit the warning,
        // so either all warnings need to be disregarded here or that particular one about unsatisfied dependency 
        // needs to be filtered out
        return slicerStatus.matches(IStatus.WARNING | IStatus.ERROR | IStatus.CANCEL);
    }

I'm running tycho 2.5

Thanks for any hints on this

@laeubi
Copy link
Member

laeubi commented Feb 1, 2022

I'm running tycho 2.5

First of all you should Upgrade to tycho 2.6.0 to be sure the problem perist and you get the latest stack-trace for error reporting.

because I use "slicer" mode

Second check would be to open the target file with PDE, does it resolves there or do you also get an error?

Thanks for any hints on this

Last but not least try to provide an integration-test to demonstrate the issue as small as possible, so we can further investigate it.

@vaclavHala
Copy link
Author

Thanks for the quick reaction.

With version 2.6.0 it behaves exactly the same. In the IDE the target file can be resolved without problem and I can use it to build and run the app.

From my description of the problem does it seem like there may be a problem for which I will try to provide the repro case or does it actually behave as intended (i.e. failing because the required dependency is not available in same location)?

Here is complete trace from the execution with 2.6.0 and -X flag

[INFO] Resolving target definition file:/targetplatform/targetplatform.target for environments=[win32/win32/x86_64, linux/gtk/x86_64], include source mode=honor, execution environment=StandardEEResolutionHints [executionEnvironment=OSGi profile 'JavaSE-11' { source level: 11, target level: 11}], remote p2 repository options=org.eclipse.tycho.p2.remote.RemoteAgent@ad05a5f0...
[ERROR] Cannot resolve target definition:
[ERROR]   Problems resolving provisioning plan.:
[ERROR]      Unable to satisfy dependency from org.eclipse.cdt.core.lrparser.feature.feature.group 9.11.0.Patch_202202011340 to org.eclipse.equinox.p2.iu; net.sourceforge.lpg.lpgjavaruntime [1.1.0.v201004271650,1.1.0.v201004271650].
[ERROR] 
[ERROR] Failed to resolve target definition file:/targetplatform/targetplatform.target: See log for details -> [Help 1]
org.apache.maven.MavenExecutionException: Failed to resolve target definition file:/targetplatform/targetplatform.target
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead (TychoMavenLifecycleParticipant.java:109)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:264)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.tycho.core.shared.BuildFailureException: Failed to resolve target definition file:/targetplatform/targetplatform.target
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver.resolveContent (TargetDefinitionResolver.java:118)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolverService.resolveFromArguments (TargetDefinitionResolverService.java:86)
    at <unknown class>.apply (Unknown Source)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent (ConcurrentHashMap.java:1705)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolverService.getTargetDefinitionContent (TargetDefinitionResolverService.java:59)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.resolveTargetDefinitions (TargetPlatformFactoryImpl.java:215)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform (TargetPlatformFactoryImpl.java:157)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform (TargetPlatformFactoryImpl.java:127)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform (TargetPlatformFactoryImpl.java:1)
    at org.eclipse.tycho.p2.manager.ReactorRepositoryManagerImpl.computePreliminaryTargetPlatform (ReactorRepositoryManagerImpl.java:86)
    at org.eclipse.tycho.p2.resolver.P2DependencyResolver.computePreliminaryTargetPlatform (P2DependencyResolver.java:226)
    at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject (DefaultTychoResolver.java:124)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.lambda$resolveProjects$0 (TychoMavenLifecycleParticipant.java:147)
    at <unknown class>.accept (Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept (ForEachOps.java:183)
    at java.util.stream.WhileOps$1$1.accept (WhileOps.java:99)
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance (ArrayList.java:1632)
    at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:127)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:515)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:501)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:487)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential (ForEachOps.java:150)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential (ForEachOps.java:173)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:239)
    at java.util.stream.ReferencePipeline.forEach (ReferencePipeline.java:497)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.resolveProjects (TychoMavenLifecycleParticipant.java:178)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead (TychoMavenLifecycleParticipant.java:105)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:264)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.tycho.p2.util.resolution.ResolverException: See log for details
    at org.eclipse.tycho.p2.util.resolution.AbstractSlicerResolutionStrategy.slice (AbstractSlicerResolutionStrategy.java:81)
    at org.eclipse.tycho.p2.util.resolution.SlicerResolutionStrategy.resolve (SlicerResolutionStrategy.java:86)
    at org.eclipse.tycho.p2.util.resolution.AbstractResolutionStrategy.multiPlatformResolve (AbstractResolutionStrategy.java:52)
    at org.eclipse.tycho.p2.util.resolution.SlicerResolutionStrategy.multiPlatformResolve (SlicerResolutionStrategy.java:79)
    at org.eclipse.tycho.p2.resolver.InstallableUnitResolver.resolve (InstallableUnitResolver.java:160)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver.resolveContentWithExceptions (TargetDefinitionResolver.java:245)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver.resolveContent (TargetDefinitionResolver.java:109)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolverService.resolveFromArguments (TargetDefinitionResolverService.java:86)
    at <unknown class>.apply (Unknown Source)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent (ConcurrentHashMap.java:1705)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolverService.getTargetDefinitionContent (TargetDefinitionResolverService.java:59)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.resolveTargetDefinitions (TargetPlatformFactoryImpl.java:215)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform (TargetPlatformFactoryImpl.java:157)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform (TargetPlatformFactoryImpl.java:127)
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform (TargetPlatformFactoryImpl.java:1)
    at org.eclipse.tycho.p2.manager.ReactorRepositoryManagerImpl.computePreliminaryTargetPlatform (ReactorRepositoryManagerImpl.java:86)
    at org.eclipse.tycho.p2.resolver.P2DependencyResolver.computePreliminaryTargetPlatform (P2DependencyResolver.java:226)
    at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject (DefaultTychoResolver.java:124)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.lambda$resolveProjects$0 (TychoMavenLifecycleParticipant.java:147)
    at <unknown class>.accept (Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept (ForEachOps.java:183)
    at java.util.stream.WhileOps$1$1.accept (WhileOps.java:99)
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance (ArrayList.java:1632)
    at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:127)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:515)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:501)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:487)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential (ForEachOps.java:150)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential (ForEachOps.java:173)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:239)
    at java.util.stream.ReferencePipeline.forEach (ReferencePipeline.java:497)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.resolveProjects (TychoMavenLifecycleParticipant.java:178)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead (TychoMavenLifecycleParticipant.java:105)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:264)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 

@laeubi
Copy link
Member

laeubi commented Feb 2, 2022

If it resolves in the IDE it should resolve in tycho, so I would consider this a bug where we do not have any test coverage for at the moment.

vaclavHala pushed a commit to vaclavHala/tycho that referenced this issue Feb 2, 2022
@vaclavHala
Copy link
Author

Here is PR with a repro case #622

If you change mode to planner in the target file the test will pass.

If you stop the test at start such that the server is running (e.g. by breakpoint) and open the target file with substituted URLs in eclipse it will resolve it fine and show its contents as expected.

One more possibly interesting observation is that the problem only manifests for dependencies from features, not from plugin manifest. The difference between the two is in that PermissiveSlicer#isApplicable returns false for plugin->plugin requirement because its req.getMatches() is ALL whereas for feature->plugin it is true because there req.getMatches() is STRICT

@laeubi
Copy link
Member

laeubi commented Feb 4, 2022

@mickaelistria what do you think should we include this with 2.7.x? I think this is clearly a bug (maybe even an undiscovered regression).

@laeubi laeubi added the bug label Feb 4, 2022
@laeubi laeubi added this to the 2.7 milestone Feb 4, 2022
@mickaelistria
Copy link
Contributor

I don't think we should commit to do anything for 2.7 any more. The more we wait, the more bugs we'll find anyway...

vaclavHala pushed a commit to vaclavHala/tycho that referenced this issue Feb 4, 2022
… from slicer as failure to be consistent with eclipse
vaclavHala pushed a commit to vaclavHala/tycho that referenced this issue Feb 7, 2022
make SlicerResolutionStrategy not consider warnings from slicer as failure to be consistent with eclipse
update tests for target resolution to expect that slicer does not fail if dependencies are missing
laeubi pushed a commit that referenced this issue Feb 8, 2022
make SlicerResolutionStrategy not consider warnings from slicer as failure to be consistent with eclipse
update tests for target resolution to expect that slicer does not fail if dependencies are missing
@laeubi
Copy link
Member

laeubi commented Feb 8, 2022

@vaclavHala this fix should be part of the snapshot now, please check if the issue is solved by
try out the current tycho snapshot build.

@laeubi laeubi closed this as completed Feb 8, 2022
@vaclavHala
Copy link
Author

Our build works fine now with 2.7.0-SNAPSHOT, thanks

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

No branches or pull requests

3 participants