Skip to content

fix: Using "current_working_dir" instead of "runfiles_dir" at write_source_files#1232

Merged
fmeum merged 1 commit intobazel-contrib:mainfrom
tokup:tokup/1223/fix-runfiles_dir
Jan 11, 2026
Merged

fix: Using "current_working_dir" instead of "runfiles_dir" at write_source_files#1232
fmeum merged 1 commit intobazel-contrib:mainfrom
tokup:tokup/1223/fix-runfiles_dir

Conversation

@tokup
Copy link
Copy Markdown
Contributor

@tokup tokup commented Jan 11, 2026

This is a fix for: write_source_files: wrong runfiles_dir assignment with runfiles enabled for windows #1223

The working dir differs when runfiles are enabled. On windows the variables are not case sensitive, so that an assignment to "runfiles_dir" overwrites the "RUNFILES_DIR" env var (which is wrong, when runfiles are enabled).

The working dir differs when runfiles are enabled.
On windows the variables are not case sensitive, so that a
assignment to "runfiles_dir" overwrites the "RUNFILES_DIR" env var.
@tokup tokup changed the title Using "current_working_dir" instead of "runfiles_dir" at write_source_files fix: Using "current_working_dir" instead of "runfiles_dir" at write_source_files Jan 11, 2026
@fmeum fmeum enabled auto-merge (squash) January 11, 2026 11:05
@aspect-workflows
Copy link
Copy Markdown

aspect-workflows bot commented Jan 11, 2026

Bazel 8 (Test)

8 test targets passed

Targets
//lib/tests/copy_to_directory:case_22_test [k8-fastbuild]                      123ms
//lib/tests/copy_to_directory_bin_action:test [k8-fastbuild]                   65ms
//lib/tests/write_source_files:a_parentpkg_test [k8-fastbuild]                 371ms
//lib/tests/write_source_files:a_subpkg_test [k8-fastbuild]                    353ms
//lib/tests/write_source_files:a_test [k8-fastbuild]                           367ms
//lib/tests/write_source_files:b_test [k8-fastbuild]                           265ms
//lib/tests/write_source_files:f_test [k8-fastbuild]                           71ms
//lib/tests/write_source_files:g_test [k8-fastbuild]                           279ms

Total test execution time was 2s. 122 tests (93.8%) were fully cached saving 39s.


Bazel 9 (Test)

8 test targets passed

Targets
//lib/tests/copy_to_directory:case_22_test [k8-fastbuild]                      134ms
//lib/tests/copy_to_directory_bin_action:test [k8-fastbuild]                   76ms
//lib/tests/write_source_files:a_parentpkg_test [k8-fastbuild]                 409ms
//lib/tests/write_source_files:a_subpkg_test [k8-fastbuild]                    320ms
//lib/tests/write_source_files:a_test [k8-fastbuild]                           324ms
//lib/tests/write_source_files:b_test [k8-fastbuild]                           431ms
//lib/tests/write_source_files:f_test [k8-fastbuild]                           143ms
//lib/tests/write_source_files:g_test [k8-fastbuild]                           467ms

Total test execution time was 2s. 122 tests (93.8%) were fully cached saving 22s.


Bazel 7 (Test)

e2e/api_entries

All tests were cache hits

1 test (100.0%) was fully cached saving 23ms.


Bazel 8 (Test)

e2e/api_entries

All tests were cache hits

1 test (100.0%) was fully cached saving 23ms.


Bazel 9 (Test)

e2e/api_entries

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/copy_action

All tests were cache hits

1 test (100.0%) was fully cached saving 20ms.


Bazel 8 (Test)

e2e/copy_action

All tests were cache hits

1 test (100.0%) was fully cached saving 21ms.


Bazel 9 (Test)

e2e/copy_action

All tests were cache hits

1 test (100.0%) was fully cached saving 33ms.


Bazel 7 (Test)

e2e/copy_to_directory

All tests were cache hits

6 tests (100.0%) were fully cached saving 309ms.


Bazel 8 (Test)

e2e/copy_to_directory

All tests were cache hits

6 tests (100.0%) were fully cached saving 295ms.


Bazel 9 (Test)

e2e/copy_to_directory

All tests were cache hits

6 tests (100.0%) were fully cached saving 263ms.


Bazel 7 (Test)

e2e/coreutils

All tests were cache hits

4 tests (100.0%) were fully cached saving 204ms.


Bazel 8 (Test)

e2e/coreutils

All tests were cache hits

4 tests (100.0%) were fully cached saving 260ms.


Bazel 9 (Test)

e2e/coreutils

All tests were cache hits

4 tests (100.0%) were fully cached saving 271ms.


Bazel 7 (Test)

e2e/external_copy_to_directory

All tests were cache hits

1 test (100.0%) was fully cached saving 20ms.


Bazel 8 (Test)

e2e/external_copy_to_directory

All tests were cache hits

1 test (100.0%) was fully cached saving 21ms.


Bazel 9 (Test)

e2e/external_copy_to_directory

All tests were cache hits

1 test (100.0%) was fully cached saving 33ms.


Bazel 7 (Test)

e2e/smoke

All tests were cache hits

4 tests (100.0%) were fully cached saving 415ms.


Bazel 8 (Test)

e2e/smoke

All tests were cache hits

4 tests (100.0%) were fully cached saving 636ms.


Bazel 9 (Test)

e2e/smoke

All tests were cache hits

4 tests (100.0%) were fully cached saving 732ms.


Bazel 7 (Test)

e2e/write_source_files

All tests were cache hits

1 test (100.0%) was fully cached saving 30ms.


Bazel 8 (Test)

e2e/write_source_files

All tests were cache hits

1 test (100.0%) was fully cached saving 28ms.


Bazel 9 (Test)

e2e/write_source_files

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.

@fmeum fmeum merged commit 8aff7dc into bazel-contrib:main Jan 11, 2026
21 of 22 checks passed
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Jan 19, 2026
This upgrade includes a Windows compatibility fix for batch file line
endings (bazel-contrib/bazel-lib#1222), which resolves a cmd parsing bug
where GOTO/CALL to labels fails when batch files use non CRLF-only line
endings and a label crosses a 512-byte boundary:
```diff
$ bazel test //deps/openssl3:module_consistency_test
[...]
==================== Test output for //deps/openssl3:module_consistency_test:
-The system cannot find the batch label specified - compare_files
+compare_files
+FAIL: files "C:\[...]\bazel-out\[...]\deps\openssl3\openssl3.MODULE.bazel.new" and "C:\[workspace]\deps\openssl3\openssl3.MODULE.bazel" differ.
+
+
+@@//deps/openssl3:openssl3.MODULE.bazel is out of date. To update this file, run:
+
+    bazel run //deps/openssl3:module_consistency
+To see differences run:
+
+    diff "C:\[...]\bazel-out\[...]\deps\openssl3\openssl3.MODULE.bazel.new" "C:\[workspace]\deps\openssl3\openssl3.MODULE.bazel"
+
================================================================================
```

Because this now surfaces we'd been generating `*.MODULE.bazel` with
OS-specific newlines, the present change fixes it by always issuing
UNIX-style newlines:
```sh
$ bazel test //deps/openssl3:module_consistency_test
[...]
//deps/openssl3:module_consistency_test                                  PASSED in 0.4s
```

`bazel_lib` 3.1.1 comes with further improvements, like:
- bazel-contrib/bazel-lib#1217
- bazel-contrib/bazel-lib#1220
- bazel-contrib/bazel-lib#1232
dd-mergequeue bot pushed a commit to DataDog/datadog-agent that referenced this pull request Jan 19, 2026
### What does this PR do?
This upgrade includes a Windows compatibility fix for batch file line endings (bazel-contrib/bazel-lib#1222), which resolves a cmd parsing bug where GOTO/CALL to labels fails when batch files use non CRLF-only line endings and a label crosses a 512-byte boundary:
```diff
> bazel test //deps/openssl3:module_consistency_test
[...]
==================== Test output for //deps/openssl3:module_consistency_test:
-The system cannot find the batch label specified - compare_files
+compare_files
+FAIL: files "C:\[...]\bazel-out\[...]\deps\openssl3\openssl3.MODULE.bazel.new" and "C:\[workspace]\deps\openssl3\openssl3.MODULE.bazel" differ.
+
+
+@@//deps/openssl3:openssl3.MODULE.bazel is out of date. To update this file, run:
+
+    bazel run //deps/openssl3:module_consistency
+To see differences run:
+
+    diff "C:\[...]\bazel-out\[...]\deps\openssl3\openssl3.MODULE.bazel.new" "C:\[workspace]\deps\openssl3\openssl3.MODULE.bazel"
+
================================================================================
```

Because this now surfaces we'd been generating `*.MODULE.bazel` with OS-specific newlines, the present change fixes it by always issuing UNIX-style newlines:
```
> bazel test //deps/openssl3:module_consistency_test
[...]
//deps/openssl3:module_consistency_test                                  PASSED in 0.4s
```

### Motivation
Keep up to date and better support colleagues working on Windows.

### Describe how you validated your changes
Locally for the time being because we still have very limited test coverage due to #44455 being disputed.

### Additional Notes
`bazel_lib` 3.1.0/3.1.1 comes with further improvements, like:
- bazel-contrib/bazel-lib#1217
- bazel-contrib/bazel-lib#1220
- bazel-contrib/bazel-lib#1232


Co-authored-by: regis.desgroppes <[email protected]>
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