Skip to content

Conversation

@mering
Copy link
Contributor

@mering mering commented Apr 28, 2025

This significantly simplifies the snippet which needs to be copied into every main script.


run_environment_info = RunEnvironmentInfo(
environment = {
"RUNFILES_BIN": "../bin",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about appending this to $PATH here directly to avoid another line in the copyable snippet but I couldn't think of a good way to get the toolchain default $PATH to append to.

# { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# # --- end runfiles.bash initialization v3 ---
#
# PATH=$PATH:$RUNFILES_BIN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work if the script is executed within an action, say a genrule? RunEnvironmentInfo only applies to bazel run, so this variable wouldn't be set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to set action env somehow in the rule as well?

Copy link
Contributor Author

@mering mering Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to cover this use case?

Would it be enough to provide a reasonable default for this case like ${RUNFILES_BIN:-bin/runfiles.bash}?

This significantly simplifies the snippet which needs to be copied
into every main script.
@mering mering force-pushed the runfiles-implicit-path branch from c585f02 to 4518418 Compare August 12, 2025 19:27
fmeum added a commit that referenced this pull request Aug 20, 2025
This avoid the need to copy&paste the verbose initialization snippet
into every script.

This should resolve the issues raised in #24.

---------

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
@mering
Copy link
Contributor Author

mering commented Aug 21, 2025

Closing this in favor of #38.

@mering mering closed this Aug 21, 2025
@mering mering deleted the runfiles-implicit-path branch August 21, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants