Skip to content

Conversation

@fmeum
Copy link
Collaborator

@fmeum fmeum commented Mar 18, 2025

%bazel_workspace% is used instead of the more conventional %workspace% to avoid changing the behavior of existing --repo_env usages in which %workspace% may already have a meaning.

RELNOTES: In environment variable values set via --repo_env, the substring %bazel_workspace% is now replaced with the absolute path of the current Bazel workspace. This can, for example, be used to make tools checked into the repository available on the PATH for repository rules.

@fmeum fmeum requested review from Wyverald and meteorcloudy March 18, 2025 09:12
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Mar 18, 2025
@fmeum fmeum force-pushed the repo-env-interpolation branch from 9e68934 to b923c3e Compare March 18, 2025 12:14
@meteorcloudy
Copy link
Member

existing --repo_env usages in which %workspace% may already have a meaning.

Do we actually know any of such use case?

@fmeum
Copy link
Collaborator Author

fmeum commented Mar 18, 2025

Do we actually know any of such use case?

No, but it doesn't seem unrealistic for some other tool to treat %workspace% in an env variable specially (https://github.com/search?q=%22%25workspace%25%22&type=code has some hits that don't look Bazel-related).

@meteorcloudy
Copy link
Member

%FOO% is actually how you reference an env var on Windows, maybe this could be a problem?

@iancha1992 iancha1992 added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Mar 18, 2025
@fmeum fmeum force-pushed the repo-env-interpolation branch 2 times, most recently from 59bb1fb to 57695d1 Compare March 20, 2025 10:33
@meteorcloudy
Copy link
Member

Do we support this for --action_env?

@fmeum
Copy link
Collaborator Author

fmeum commented Mar 25, 2025

We could, but I don't think that's a step in the right direction. If you have in-repo tools, IMO you should wrap them in targets and depend on those in your rules rather than non-hermetically adding them to PATH.

I still haven't figured out the remaining CI issue. It seems to be related to MSYS/Windows path styles.

@fmeum fmeum force-pushed the repo-env-interpolation branch from ca82607 to ba0d24e Compare April 25, 2025 10:18
@fmeum fmeum removed request for a team, Wyverald, brandjon and tetromino April 25, 2025 10:18
@fmeum fmeum force-pushed the repo-env-interpolation branch from ba0d24e to a43adf8 Compare April 25, 2025 10:52
@fmeum fmeum force-pushed the repo-env-interpolation branch 2 times, most recently from 4433b58 to 42e0618 Compare November 3, 2025 17:47
`%bazel_workspace%` is used instead of the more conventional `%workspace%` to avoid changing the behavior of existing `--repo_env` usages in which `%workspace%` may already have a meaning.

RELNOTES: In environment variable values set via `--repo_env`, the substring `%bazel_workspace%` is now replaced with the absolute path of the current Bazel workspace. This can, for example, be used to make tools checked into the repository available on the `PATH` for repository rules.
@fmeum fmeum force-pushed the repo-env-interpolation branch from b118151 to 057ff26 Compare November 4, 2025 09:16
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 4, 2025

@meteorcloudy Tests are passing now

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Nov 4, 2025
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 4, 2025

@bazel-io fork 9.0.0

@copybara-service copybara-service bot closed this in 6dc16b9 Nov 6, 2025
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Nov 6, 2025
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Nov 6, 2025
`%bazel_workspace%` is used instead of the more conventional `%workspace%` to avoid changing the behavior of existing `--repo_env` usages in which `%workspace%` may already have a meaning.

RELNOTES: In environment variable values set via `--repo_env`, the substring `%bazel_workspace%` is now replaced with the absolute path of the current Bazel workspace. This can, for example, be used to make tools checked into the repository available on the `PATH` for repository rules.

Closes bazelbuild#25608.

PiperOrigin-RevId: 828862407
Change-Id: I644fbb25d80c5353e522c7184d7c57b2ac8bf04f
github-merge-queue bot pushed a commit that referenced this pull request Nov 6, 2025
…7562)

`%bazel_workspace%` is used instead of the more conventional
`%workspace%` to avoid changing the behavior of existing `--repo_env`
usages in which `%workspace%` may already have a meaning.

RELNOTES: In environment variable values set via `--repo_env`, the
substring `%bazel_workspace%` is now replaced with the absolute path of
the current Bazel workspace. This can, for example, be used to make
tools checked into the repository available on the `PATH` for repository
rules.

Closes #25608.

PiperOrigin-RevId: 828862407
Change-Id: I644fbb25d80c5353e522c7184d7c57b2ac8bf04f

Commit
6dc16b9

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants