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

Crash in vendor subcommand #23521

Closed
criemen opened this issue Sep 5, 2024 · 8 comments
Closed

Crash in vendor subcommand #23521

criemen opened this issue Sep 5, 2024 · 8 comments
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@criemen
Copy link
Contributor

criemen commented Sep 5, 2024

Description of the bug:

 criemen@Corneliuss-MBP  ~/repos/semmle-code   main ±  bazel vendor --vendor_dir=vendor_src //...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: a3f127d2-153b-400d-8a1e-55c75c5d6396
Loading: 1 packages loaded
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@@WORKSPACE.bazel' (requested by nodes '[/private/var/tmp/_bazel_criemen/267ec2c545f0139b2caed9502387afe1]/[external/WORKSPACE.bazel]')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:550)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.ClassCastException: class com.google.devtools.build.lib.packages.InputFile cannot be cast to class com.google.devtools.build.lib.packages.Rule (com.google.devtools.build.lib.packages.InputFile and com.google.devtools.build.lib.packages.Rule are in unnamed module of loader 'app')
        at com.google.devtools.build.lib.packages.Package.getRule(Package.java:615)
        at com.google.devtools.build.lib.repository.ExternalPackageHelper$ExternalPackageRuleExtractor.processAndShouldContinue(ExternalPackageHelper.java:144)
        at com.google.devtools.build.lib.repository.ExternalPackageHelper.iterateWorkspaceFragments(ExternalPackageHelper.java:118)
        at com.google.devtools.build.lib.repository.ExternalPackageHelper.getRuleByName(ExternalPackageHelper.java:52)
        at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.getRepoRuleFromWorkspace(RepositoryDelegatorFunction.java:475)
        at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.getRepositoryRule(RepositoryDelegatorFunction.java:360)
        at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.compute(RepositoryDelegatorFunction.java:154)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:461)
        ... 7 more

Presumably some symlink or something in our source root messes up the vendor subcommand - it shouldn't crash with an exception though.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

MacOS

What is the output of bazel info release?

development

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

5f5d70b via bazelisk (it's a commit from the 7.4.0 branch)

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@fmeum
Copy link
Collaborator

fmeum commented Sep 5, 2024

@meteorcloudy

@sgowroji sgowroji added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Sep 5, 2024
@meteorcloudy
Copy link
Member

REPOSITORY_DIRECTORY:@@WORKSPACE.bazel

This looks very weird, do you actually have a repo called WORKSPACE.bazel somehow? Can you provide a minimal reproducible case?

@criemen
Copy link
Contributor Author

criemen commented Sep 10, 2024

do you actually have a repo called WORKSPACE.bazel somehow?

No, unless one of our transitive dependencies has one (that'd be weird though).

Can you provide a minimal reproducible case?

Not anytime soon, but if you're fine with waiting then I'll get back to you eventually.

@moroten
Copy link
Contributor

moroten commented Sep 17, 2024

After running bazel vendor, I got stuck with the same error when running bazel test using Bazel 7.3.1:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@@WORKSPACE' (requested by nodes '[/<redacted>/e9607a41d9]/[external/WORKSPACE]')

@moroten
Copy link
Contributor

moroten commented Sep 17, 2024

The crash loop does not get resolved by bazel clean --expunge, only by removing the vendor directory.

I can reproduce it by running

touch WORKSPACE
mkdir vendor
ln -s $(bazel info output_base)/external vendor/bazel-external
bazel test ...

@moroten
Copy link
Contributor

moroten commented Sep 17, 2024

Duplicates #22740

@meteorcloudy
Copy link
Member

#23771 should help avoid this. A temporary solution is to add the vendor dir into .bazelignore.

@meteorcloudy meteorcloudy added P1 I'll work on this now. (Assignee required) and removed under investigation labels Sep 27, 2024
@meteorcloudy meteorcloudy self-assigned this Sep 27, 2024
@meteorcloudy meteorcloudy added the area-Bzlmod Bzlmod-specific PRs, issues, and feature requests label Sep 27, 2024
meteorcloudy added a commit to meteorcloudy/bazel that referenced this issue Oct 9, 2024
- Adding `--vendor_dir` to ignored package prefixes as if it's added in the `.bazelignore` file.
- This allows users to do `bazel build //...` after vendoring external deps in the source root without manually adding the vendor dir in `.bazelignore`.

Fixes bazelbuild#23521

Closes bazelbuild#23771.

PiperOrigin-RevId: 680994986
Change-Id: I9c8b76ca20b9060232dfe05460a8fc857c92e93f
meteorcloudy added a commit that referenced this issue Oct 9, 2024
- Adding `--vendor_dir` to ignored package prefixes as if it's added in
the `.bazelignore` file.
- This allows users to do `bazel build //...` after vendoring external
deps in the source root without manually adding the vendor dir in
`.bazelignore`.

Fixes #23521

Closes #23771.

PiperOrigin-RevId: 680994986
Change-Id: I9c8b76ca20b9060232dfe05460a8fc857c92e93f

Backporting
d42301b
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.4.0 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.4.0rc1. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants