bazelbuild / bazelbuild/bazel

How to use a sub-repo that has a bazel csharp project in it?

Open
#25,844 0 comments 0 reactions 0 assignees View on GitHub
team-Core type: bug untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

I'm trying to figure out how to use a tool that is implemented in a gitlab repo with bazel build files, in a higher level bazel project.

**Gitlab1 - code-generator**
- dotnet libraries and a dotnet binary "//cli:cli"
- dependencies referenced in BUILD.bazel files as e.g. @paket.codegen//:newtonsoft.json
- uses rules_dotnet and paket to pull dependencies:
```
codegen_extension = use_extension("//bazel/repo/csharp:paket.codegen_extension.bzl", "codegen_extension")
use_repo(codegen_extension, "paket.codegen")
```

Build of gitlab1 within gitlab1 works fine:
**gitlab1> bazel build //cli**
`INFO: Build completed successfully, 23 total actions`

**Gitlab2 - Higher level project**
- Module.bazel file
- code-generator referenced via http_archive inside a module extension named "gitlab"

In the context of gitlab2, I feel I should be able to build the code from gitlab1:

**gitlab2> bazel build @code-generator//cli**
```
ERROR: no such package '@@[unknown repo 'paket.codegen' requested from @@+gitlab+code-generator]//newtonsoft.json': The repository '@@[unknown repo 'paket.codegen' requested from @@+gitlab+code-generator]' could not be resolved: No repository visible as '@paket.codegen' from repository '@@+gitlab+code-generator'
```

Both projects are bazel 8.1.1 with modules enabled

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

Windows

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

release 8.1.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 with the higher-level project's Module.bazel and the code-generator's BUILD.bazel files, then inspect //bazel/repo/csharp:paket.codegen_extension.bzl and the gitlab module extension. Reproduce bazel build @code-generator//cli on Bazel 8.1.1; done means the nested paket.codegen repository resolves and the target builds successfully.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.