Skip to content

Inconsistent RUNFILES locations on windows #4261

Closed

Description

@wyan-nestlabs

Please provide the following information. The more we know about your system and use case, the more easily and likely we can help.

Description of the problem / feature request / question:

If asking a question or requesting a feature, also tell us about the underlying problem you're trying to solve.

If possible, provide a minimal example to reproduce the problem:

Environment info

  • Operating System:
    Windows Server 2012 R2

  • Bazel version (output of bazel info release):
    0.8.0

Have you found anything relevant by searching the web?

(e.g. StackOverflow answers,
GitHub issues,
email threads on the bazel-discuss Google group)
No.

Anything else, information or logs or outputs that would be helpful?

(If they are large, please upload as attachment or provide link).

Code: https://gist.github.com/wyan-nestlabs/089cc4952b80cd2f30d2a0a89a9913a7

$ bazel run :shell_wrapper
Loading:
Loading: 0 packages loaded
INFO: Analysed target //:shell_wrapper (0 packages loaded).
INFO: Found 1 target...
[0 / 5] BazelWorkspaceStatusAction stable-status.txt
Target //:shell_wrapper up-to-date:
  C:/cygwin64/tmp/_bazel_wyan/zgiahg30/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/shell_wrapper
  C:/cygwin64/tmp/_bazel_wyan/zgiahg30/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/shell_wrapper.exe
INFO: Elapsed time: 0.305s, Critical Path: 0.01s
INFO: Build completed successfully, 3 total actions

INFO: Running command line: C:/cygwin64/tmp/_bazel_wyan/zgiahg30/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/shell_wrapper.exe ./hello_world.exe ./app.conf
PWD: /c/cygwin64/tmp/_bazel_wyan/zgiahg30/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/shell_wrapper.exe.runfiles
===============================
MANIFEST
===============================
RUNFILES: C:\cygwin64\tmp\_bazel_wyan\zgiahg30\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\shell_wrapper.runfiles
===============================
dir: cannot access 'C:\cygwin64\tmp\_bazel_wyan\zgiahg30\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\shell_wrapper.runfiles': No such file or directory
===============================
dir: cannot access './hello_world.exe': No such file or directory
dir: cannot access './app.conf': No such file or directory

There are two problems:

  1. the PWD path's last section is shell_wrapper.exe.runfiles, but RUNFILES variable value does not have .exe in the path. So RUNFILES is an invalid path.
  2. app.conf is a source file. It is not in RUNFILES directory.

Both problems happen only on Windows. On Ubuntu, the RUNFILES is /home/wyan/.cache/bazel/_bazel_wyan/f48...26b/execroot/main/bazel-out/k8-fastbuild/bin/gcs_upload_wrapper.runfiles/main and all the files list in "data" are there.

Activity

  1. laszlocsomor commented on Dec 11, 2017

    @laszlocsomor
    Contributor

    the PWD path's last section is shell_wrapper.exe.runfiles, but RUNFILES variable value does not have .exe in the path. So RUNFILES is an invalid path.

    Bazel doesn't create a runfiles tree on Windows, it only does so on Linux/macOS. The value of $RUNFILES is bogus. (Arguably Bazel shouldn't even set it on Windows.)

    On Windows Bazel creates a runfiles manifest, which is a text file that describes how the runfiles tree would look like. In each line there's a pair of paths: a relative path that on Linux/macOS would be the path of the symlink (under $0.runfiles), and an absolute path that on Linux/macOS would be the path of the symlink target.

    To use runfiles on Windows, you have to grep the manifest file:

    grep "^path/to/file" "$RUNFILES_MANIFEST_FILE"
    

    app.conf is a source file. It is not in RUNFILES directory.

    I don't understand the issue here. What was your expectation and what happened instead?

  2. self-assigned this
    on Dec 11, 2017
  3. wyan-nestlabs commented on Dec 11, 2017

    @wyan-nestlabs
    Author

    the PWD path's last section is shell_wrapper.exe.runfiles, but RUNFILES variable value does not have .exe in the path. So RUNFILES is an invalid path.

    Bazel doesn't create a runfiles tree on Windows, it only does so on Linux/macOS. The value of $RUNFILES is bogus. (Arguably Bazel shouldn't even set it on Windows.)

    I see it now. I guess it is OK to have RUNFILES with only MANIFEST inside. I have to requests:

    1. the PWD dir sh_binary executed in should be RUNFILES. Currently
      PWD: /c/cygwin64/tmp/_bazel_wyan/zgiahg30/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/shell_wrapper.exe.runfiles # Has '.exe' in last segment of path, Exist in filesystem.
      RUNFILES: C:\cygwin64\tmp\_bazel_wyan\zgiahg30\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\shell_wrapper.runfiles # Not exist in filesystem
    2. Document the windows specific behaviour at right place, i.e. https://docs.bazel.build/versions/master/output_directories.html. Bazel on Windows may desire a dedicated page on useage. Currently there is only the installation instruction on Windows.

    app.conf is a source file. It is not in RUNFILES directory.

    I don't understand the issue here. What was your expectation and what happened instead?
    app.conf is in "data" to

    app.conf is in sh_binary's "data" and is a source. So I was expecting it in RUNFILES too. I see it in MANIFEST. So it is clear now.

  4. laszlocsomor commented on Dec 12, 2017

    @laszlocsomor
    Contributor
    1. I agree, $RUNFILES should point to the actual runfiles directory (with .exe in the name). I created runfiles, Windows: $RUNFILES should point to the actual runfiles directory #4280 to track this.
    2. I created a separate issue for that: docs, Windows, runfiles: document runfiles semantics on Windows [duplicate of #6402] #4279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions