Skip to content

Commit e8ec91b

Browse files
committed
fix #3101 - Normalize stub_path in repl.bzl
When a REPL target is run from an external Bazel module, the `stub_path` can have path components in it (e.g. "/..") which get rejected by the `Rlocation()` in `runfiles.py`. This commit normalizes the path before it's passed to `Rlocation()`.
1 parent f02c9c7 commit e8ec91b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/private/repl.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Implementation of the rules to expose a REPL."""
22

33
load("//python:py_binary.bzl", _py_binary = "py_binary")
4+
load("@bazel_skylib//lib:paths.bzl", "paths")
45

56
def _generate_repl_main_impl(ctx):
67
stub_repo = ctx.attr.stub.label.repo_name or ctx.workspace_name
7-
stub_path = "/".join([stub_repo, ctx.file.stub.short_path])
8+
unnormalized_path = "/".join([stub_repo, ctx.file.stub.short_path])
9+
stub_path = paths.normalize(unnormalized_path)
810

911
out = ctx.actions.declare_file(ctx.label.name + ".py")
1012

0 commit comments

Comments
 (0)