I have a weird rule error I don't understand, at l...
# plugins
g
I have a weird rule error I don't understand, at least not fully. I have the following two rules:
Copy code
@rule(desc="Find all cargo packages in project")
def find_all_cargo_targets(all_targets: AllTargets) -> AllCargoTargets:
    ...

@rule(desc="Assign packages to workspaces")
async def assign_packages_to_workspaces(
    all_cargo_targets: AllCargoTargets,
) -> CargoPackageMapping:
    ...
And I'm now implementing a new goal;
generate-lockfiles
, which should make use of this.
Copy code
@rule
async def determine_rust_user_resolves(
    _: KnownCargoUserResolveNamesRequest,
    cargo_targets: AllCargoTargets,
) -> KnownUserResolveNames:
    ...
works, but if I replace the second argument with a
CargoPackageMapping
or try to query for one inside that rule, it breaks the rule graph. I'm assuming this is because of something that the
assign_package_to_workspaces
rule does, but the only things it looks for is
SourceFiles
,
DigestContents
, and
RawSpecs
. Neither of those should - I think? - need resolves to be known. Or maybe they do, in order to validate fields..?
1
The errors aren't super helpful, though they mention SourceFiles a few times...
Copy code
No installed rules return the type BuildTargetIdentifier, and it was not provided by potential callers of @rule(pants.bsp.util_rules.targets:212:resolve_bsp_build_target_identifier(BuildTargetIdentifier, BSPBuildTargets) -> BSPBuildTargetInternal).
    If that type should be computed by a rule, ensure that that rule is installed.
    If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
  No installed rules return the type CargoSourcesRequest, and it was not provided by potential callers of @rule(pants_cargo_porcelain.util_rules.sandbox:16:cargo_sources(CargoSourcesRequest) -> SourceFiles, gets=[Get(TransitiveTargets, [TransitiveTargetsRequest]), Get(SourceFiles, [SourceFilesRequest])]).
    If that type should be computed by a rule, ensure that that rule is installed.
    If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
  No installed rules return the type EnvironmentNameRequest, and it was not provided by potential callers of @rule(pants.core.util_rules.environments:694:resolve_environment_name(EnvironmentNameRequest, EnvironmentsSubsystem, GlobalOptions) -> EnvironmentName, gets=[ChosenLocalEnvironmentName, Get(EnvironmentTarget, [EnvironmentName]), Get(EnvironmentName, [EnvironmentNameRequest])]).
    If that type should be computed by a rule, ensure that that rule is installed.
    If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
  No installed rules return the type KnownPythonUserResolveNamesRequest, and it was not provided by potential callers of @rule(pants.backend.python.goals.lockfile:210:determine_python_user_resolves(KnownPythonUserResolveNamesRequest, PythonSetup) -> KnownUserResolveNames).
    If that type should be computed by a rule, ensure that that rule is installed.
    If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
  No installed rules return the type SingleEnvironmentNameRequest, and it was not provided by potential callers of @rule(pants.core.util_rules.environments:660:resolve_single_environment_name(SingleEnvironmentNameRequest) -> EnvironmentName, gets=[Get(EnvironmentName, [EnvironmentNameRequest])]).
    If that type should be computed by a rule, ensure that that rule is installed.
    If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
  No installed rules return the type _ParseOneBSPMappingRequest, and it was not provided by potential callers of @rule(pants.bsp.util_rules.targets:137:parse_one_bsp_mapping(_ParseOneBSPMappingRequest) -> BSPBuildTargetInternal).
    If that type should be computed by a rule, ensure that that rule is installed.
    If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
  No source of dependency BSPBuildTargets for @rule(pants.bsp.util_rules.targets:212:resolve_bsp_build_target_identifier(BuildTargetIdentifier, BSPBuildTargets) -> BSPBuildTargetInternal). All potential sources were eliminated: []
  No source of dependency ChosenLocalEnvironmentName for @rule(pants.core.util_rules.environments:694:resolve_environment_name(EnvironmentNameRequest, EnvironmentsSubsystem, GlobalOptions) -> EnvironmentName, gets=[ChosenLocalEnvironmentName, Get(EnvironmentTarget, [EnvironmentName]), Get(EnvironmentName, [EnvironmentNameRequest])]). All potential sources were eliminated: []
  No source of dependency EnvironmentsSubsystem for @rule(pants.core.util_rules.environments:694:resolve_environment_name(EnvironmentNameRequest, EnvironmentsSubsystem, GlobalOptions) -> EnvironmentName, gets=[ChosenLocalEnvironmentName, Get(EnvironmentTarget, [EnvironmentName]), Get(EnvironmentName, [EnvironmentNameRequest])]). All potential sources were eliminated: []
  No source of dependency Get(EnvironmentName, [EnvironmentNameRequest]) for @rule(pants.core.util_rules.environments:660:resolve_single_environment_name(SingleEnvironmentNameRequest) -> EnvironmentName, gets=[Get(EnvironmentName, [EnvironmentNameRequest])]). All potential sources were eliminated: []
  No source of dependency Get(EnvironmentName, [EnvironmentNameRequest]) for @rule(pants.core.util_rules.environments:694:resolve_environment_name(EnvironmentNameRequest, EnvironmentsSubsystem, GlobalOptions) -> EnvironmentName, gets=[ChosenLocalEnvironmentName, Get(EnvironmentTarget, [EnvironmentName]), Get(EnvironmentName, [EnvironmentNameRequest])]). All potential sources were eliminated: []
  No source of dependency Get(EnvironmentTarget, [EnvironmentName]) for @rule(pants.core.util_rules.environments:694:resolve_environment_name(EnvironmentNameRequest, EnvironmentsSubsystem, GlobalOptions) -> EnvironmentName, gets=[ChosenLocalEnvironmentName, Get(EnvironmentTarget, [EnvironmentName]), Get(EnvironmentName, [EnvironmentNameRequest])]). All potential sources were eliminated: []
  No source of dependency Get(SourceFiles, [SourceFilesRequest]) for @rule(pants_cargo_porcelain.util_rules.sandbox:16:cargo_sources(CargoSourcesRequest) -> SourceFiles, gets=[Get(TransitiveTargets, [TransitiveTargetsRequest]), Get(SourceFiles, [SourceFilesRequest])]). All potential sources were eliminated: []
  No source of dependency Get(TransitiveTargets, [TransitiveTargetsRequest]) for @rule(pants_cargo_porcelain.util_rules.sandbox:16:cargo_sources(CargoSourcesRequest) -> SourceFiles, gets=[Get(TransitiveTargets, [TransitiveTargetsRequest]), Get(SourceFiles, [SourceFilesRequest])]). All potential sources were eliminated: []
  No source of dependency GlobalOptions for @rule(pants.core.util_rules.environments:694:resolve_environment_name(EnvironmentNameRequest, EnvironmentsSubsystem, GlobalOptions) -> EnvironmentName, gets=[ChosenLocalEnvironmentName, Get(EnvironmentTarget, [EnvironmentName]), Get(EnvironmentName, [EnvironmentNameRequest])]). All potential sources were eliminated: []
Yeah... This snippet is what breaks it:
Copy code
@rule(desc="Load Cargo.toml for Cargo target")
async def load_cargo_toml(request: CargoTomlRequest) -> CargoToml:
    files = await Get(
        SourceFiles,
        SourceFilesRequest(
            [request.sources],
        ),
    )
Oh yeah, yepp. That might generate sources, which could need resolves.
So that's a bit of a pain, I want to generate resolves from targets because nothing else is sensible from Rust because resolve-setup is predetermined from the files
Copy code
snapshot = await Get(
        Snapshot,
        PathGlobs,
        request.sources.path_globs(UnmatchedBuildFileGlobs.error()),
    )
a bit roundabout but solves it 🤷