aspect-build / aspect-build/rules_lint

[Bug]: Clippy fails when rust target has generated inputs

Open
#786 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Starlark
Stars
154
Forks
125
Avg merge
3d 21h
Merged PRs (30d)
20

Description

### What happened?

When a rust_library/rust_binary has a generated input the Clippy aspect in rules_lint fails due to conflicting generated files.

Reproduction can be found here: https://github.com/purkhusid/rules_lint/tree/clippy-repro

I'm going to continue debugging this to find the root cause but just wanted to create the issue in case @blorente might know a obvious fix.

### Version

Development (host) and target OS/architectures:

Output of `bazel --version`: 9.0.0

rules_lint at HEAD

Language(s) and/or frameworks involved:
Rust

### How to reproduce

Repro here: https://github.com/purkhusid/rules_lint/tree/clippy-repro
Run `cd examples/rust && bazel build //... --@aspect_rules_lint//lint:fix` to get the following error:
```shell

ERROR: file 'src/ok_binary.rs' is generated by these conflicting actions:
Label: //src:ok_binary_with_generated_inputs
Aspects: [//tools/lint:linters.bzl%clippy], []
RuleClass: rust_binary rule
JavaActionClass: class com.google.devtools.build.lib.analysis.actions.StarlarkAction, class com.google.devtools.build.lib.analysis.actions.SymlinkAction
Configuration: 25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105
Mnemonic: CopyFile, Symlink
IsShareable: true
Action key: 79c0e22133eccc03c26a734724830c24b43bfeed90bf33fd989c0d639a6476d5, c90914cc1e7ea06f84518cf4f179e63dbd20dad9358a550644494828e4a4ed28
Progress message: Copying file src/ok_binary.rs, Creating symlink to source file: src/ok_binary.rs
Action describeKey: Copying file src/ok_binary.rs
Execution info: no-sandbox=1
Argument: external/bazel_lib++toolchains+coreutils_linux_amd64/coreutils
Argument: cp
Argument: src/ok_binary.rs
Argument: bazel-out/k8-fastbuild/bin/src/ok_binary.rs
Output paths mode: OFF
, GUID: 7f4fab4d-d0a7-4f0f-8649-1d0337a21fee
inputPath: null

PrimaryInput: File:[/home/danielp/dannidev/repos/purkhusid/rules_lint/examples/rust[source]]src/ok_binary.rs
PrimaryOutput: File:[[]bazel-out/k8-fastbuild/bin]src/ok_binary.rs
Owner information: SimpleAspectKey{baseConfiguredTargetKey=ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}, aspectDescriptor=//tools/lint:linters.bzl%clippy}, ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}
MandatoryInputs: Attempted action contains artifacts not in previous action (first 5):
coreutils
Outputs: are equal
ERROR: file 'src/ok_binary.rs' is generated by these conflicting actions:
Label: //src:ok_binary_with_generated_inputs
Aspects: [//tools/lint:linters.bzl%clippy], []
RuleClass: rust_binary rule
JavaActionClass: class com.google.devtools.build.lib.analysis.actions.StarlarkAction, class com.google.devtools.build.lib.analysis.actions.SymlinkAction
Configuration: 25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105
Mnemonic: CopyFile, Symlink
IsShareable: true
Action key: 79c0e22133eccc03c26a734724830c24b43bfeed90bf33fd989c0d639a6476d5, c90914cc1e7ea06f84518cf4f179e63dbd20dad9358a550644494828e4a4ed28
Progress message: Copying file src/ok_binary.rs, Creating symlink to source file: src/ok_binary.rs
Action describeKey: Copying file src/ok_binary.rs
Execution info: no-sandbox=1
Argument: external/bazel_lib++toolchains+coreutils_linux_amd64/coreutils
Argument: cp
Argument: src/ok_binary.rs
Argument: bazel-out/k8-fastbuild/bin/src/ok_binary.rs
Output paths mode: OFF
, GUID: 7f4fab4d-d0a7-4f0f-8649-1d0337a21fee
inputPath: null

PrimaryInput: File:[/home/danielp/dannidev/repos/purkhusid/rules_lint/examples/rust[source]]src/ok_binary.rs
PrimaryOutput: File:[[]bazel-out/k8-fastbuild/bin]src/ok_binary.rs
Owner information: SimpleAspectKey{baseConfiguredTargetKey=ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}, aspectDescriptor=//tools/lint:linters.bzl%clippy}, ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}
MandatoryInputs: Attempted action contains artifacts not in previous action (first 5):
coreutils
Outputs: are equal
```

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the clippy aspect entry point in tools/lint/linters.bzl and reproduce the failure from the clippy-repro branch using `cd examples/rust && bazel build //... --@aspect_rules_lint//lint:fix`. Compare the generated input handling for `//src:ok_binary_with_generated_inputs` with the conflicting CopyFile and Symlink actions. Done means the reproduction builds without conflicting generated-file actions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.