Relative path resolution from data files on Windows cannot map back to runfiles #5926
Labels
area-Windows
Windows-specific issues and feature requests
P2
We'll consider working on this in future. (Assignee optional)
platform: windows
team-OSS
Issues for the Bazel OSS team: installation, release processBazel packaging, website
type: feature request
Description of the problem / feature request:
When a data file is resolved on Windows via the runfiles manifest it is resolved back to the workspace path.
Since this path is in the user workspace relative resolutions from it will yield paths in the workspace and not the execroot.
In Linux/OSX this is not a problem because the data file path resolves to a symlink in the execroot, and thus relative paths from there will still be in the execroot.
In some cases the data file path needs to be used as a base path from which to resolve relative paths. This is common in the NodeJS ecosystem, where code loads JSON files that contain paths to other modules that need to be loaded.
But once we have an absolute path inside the workspace folder, relative paths from that file will still be absolute paths in the workspace and cannot be looked up in the manifest.
This becomes a bigger problem when passing data paths to third party libraries, since on those we have no control over how those files are processed or used.
In the reproduction section next I will give a concrete example.
Note: the problem here is described for data files, but this also happens for source files that do not need to be built.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
You should see the following on the test log when running
bazel test ...
on Windows:D:\sandbox\windows-data-runfiles\
is my local workspace path, and https://github.com/bazelbuild/rules_nodejs is used for module resolution (including runfiles).Below are the relevant runfile mappings on my machine:
Resolving the data file follows this logic:
D:/sandbox/windows-data-runfiles/data_runfiles.spec.js
./data.json
__main__/data_runfiles.spec.js
__main__/data.json
D:/sandbox/windows-data-runfiles/data.json
./data.json
fromD:/sandbox/windows-data-runfiles/data_runfiles.spec.js
resolves toD:/sandbox/windows-data-runfiles/data.json
Inside the data file there is a relative path to another module that needs to be loaded (
relative_module_built.js
).Performing path manipulation we join the directory name of the data file (
D:/sandbox/windows-data-runfiles/
) with the relative path to obtainD:/sandbox/windows-data-runfiles/relative_module_built.js
.This file does not exist in the workspace path because it is a built file, and this absolute path cannot be resolved via the manifest either because it does not match any of the entries.
What operating system are you running Bazel on?
Windows 10
What's the output of
bazel info release
?release 0.16.1
Have you found anything relevant by searching the web?
I couldn't find anything for this topic specifically, but there were a couple of other issues about data files in Windows #4054, #3881
/cc @alexeagle @meteorcloudy
The text was updated successfully, but these errors were encountered: