bazelbuild / bazelbuild/bazel

Linking failed: Could not copy inputs into sandbox: <path>/lib64 (Is a directory)

Open
#27,028 5 comments 0 reactions 0 assignees View on GitHub
awaiting-user-response team-Local-Exec type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the bug:

I'm using a custom cc_toolchain where I'm setting each attribute using filegroups obtained via globs, like the following:
```
cc_toolchain(
name = "_cc_toolchain",
all_files = ":all_files",
ar_files = ":ar_files",
as_files = ":as_files",
compiler_files = ":compiler_files",
... etc.
)
filegroup(
name = "all_files",
srcs = glob(["**"]),
)
... etc.
```

I'm also compiling my C++ files using cc_library/cc_binary in a Docker sandbox. There are 9000 files in the toolchain and that results in a lot of IO overhead. Trying to reduce the overhead, I've switched the filegroups to point to directories instead, but with no successful results.

- With `filegroup(name = "all_files", srcs = ["."])`:
I'm getting:
`WARNING: Directory artifact crosses package boundary into package rooted at tools/toolchains`
and
`ERROR: external/+_repo_rules+flatbuffers/src/BUILD.bazel:9:11: Compiling src/idl_parser.cpp failed: Exec failed due to IOException: The file type of 'external/+_repo_rules2+gcc_10.3.0_x86_tool/x86_64-buildroot-linux-gnu/lib64/libgfortran.so.5' is not supported.`

- Referencing individual directories, with `filegroup(name = "all_files", srcs = ["bin", "include", "lib", "lib64", ...])`:
I'm getting:
`ERROR: /external/googletest+/BUILD.bazel:86:11: Linking external/googletest+/libgtest.so failed: Could not copy inputs into sandbox: /execroot/_main/external/+_repo_rules2+gcc_10.3.0_x86_tool/lib64 (Is a directory)`

### Which category does this issue belong to?

Local Execution

### 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?

WSL2 Ubuntu 22.04

### What is the output of `bazel info release`?

release 8.4.1

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

_No response_

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

```text

```

### 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_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the custom cc_toolchain and directory-based filegroups described in the issue on WSL2 Ubuntu 22.04 with Bazel 8.4.1. Trace the local-execution sandbox input-copying path from the reported “Could not copy inputs into sandbox” error; done means the reproduction no longer treats directory artifacts as unsupported link inputs.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
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.