Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Runfiles on Windows #1212

Closed
dslomov opened this issue Apr 29, 2016 · 10 comments
Closed

Support Runfiles on Windows #1212

dslomov opened this issue Apr 29, 2016 · 10 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) platform: windows type: documentation (cleanup)
Milestone

Comments

@dslomov
Copy link
Contributor

dslomov commented Apr 29, 2016

Currently build-runfiles.exe uncoditionally creates hardlinks to individual runfiles on Windows.
This is problematic on several levels:

  • if the target of hard link is deleted, we should unlink the link in runfiles and relink...
  • ..but unlinking hardlinks is not allowed if the target of hardlink cannot be written to (for permission issues or because it is exclusively locked).
@dslomov dslomov self-assigned this Apr 29, 2016
@dslomov dslomov added P1 I'll work on this now. (Assignee required) platform: windows labels Apr 29, 2016
@dslomov dslomov added this to the 0.4 milestone Apr 29, 2016
bazel-io pushed a commit that referenced this issue May 10, 2016
On Windows, we use hard links in runfiles tree, and we need
to delete and recreate all of them on every runfiles tree update
(otherwise the links might still point to outdated files).
Occasionally the hard link cannot be unlinked (due to permissions
or file being busy). This CL just ignores the error (and hopes for the best).
This will allow us to make progress on Windows.

Work towards #1212.

--
MOS_MIGRATED_REVID=121949474
bazel-io pushed a commit that referenced this issue Jun 21, 2016
This adds a new configuration option that allows disabling the creation of symlink forest for runfiles.
On Windows, symlink forest is disabled by default; only the runfiles manifest is created.

For shell tests, a function 'rlocation' is provided that converts from runfiles location to a real location.

Work towards #1212.

--
MOS_MIGRATED_REVID=125439553
hermione521 pushed a commit to hermione521/bazel that referenced this issue Jun 27, 2016
This adds a new configuration option that allows disabling the creation of symlink forest for runfiles.
On Windows, symlink forest is disabled by default; only the runfiles manifest is created.

For shell tests, a function 'rlocation' is provided that converts from runfiles location to a real location.

Work towards bazelbuild#1212.

--
MOS_MIGRATED_REVID=125439553
@dslomov dslomov changed the title Fix build-runfiles on Windows Support Runfiles on Windows Jun 29, 2016
@dslomov
Copy link
Contributor Author

dslomov commented Sep 5, 2016

Need to document the current plan for runfiles.

@petemounce
Copy link
Contributor

Does this get put into milestone 0.5, or is it still possible to ship in the 0.4.x

@damienmg
Copy link
Contributor

damienmg commented Nov 2, 2016

We do not version documentation yet. I think this should be done ASAP now.

@petemounce
Copy link
Contributor

Oh - I meant this ticket, not the docs output of it.

@damienmg damienmg modified the milestones: 0.5, 0.4 Nov 11, 2016
@dslomov dslomov modified the milestones: 0.6, 0.5 Feb 14, 2017
@dslomov dslomov modified the milestones: 0.7, 0.6 Jul 24, 2017
@laszlocsomor
Copy link
Contributor

Infeasible.

Non-elevated (not running as Administrator) processes cannot create symlinks, and we don't want to require elevation to run builds.

Bazel writes runfiles manifest files instead, that describe the mapping.

@gkalpak
Copy link
Contributor

gkalpak commented Jun 19, 2018

@laszlocsomor : Since it now possible to enable creating symlinks on Windows without admin rights or UAC (:tada:), is there a way to tell bazel to create symlinks as it would on linux (instead of creating a RUNFILES_MANIFEST_FILE?
(If not, there really should be 🙏

@laszlocsomor
Copy link
Contributor

Hey @gkalpak : sure it would be possible, but I'm afraid we don't have capacity to do the migration, plus this would make it impossible to support older Windows versions (since this feature requires Win 10, v1709). That said, it is much easier now to use runfiles on Windows, thanks to the language-specific runfiles libraries (see below).

Usage:

  1. Depend on the specific runfiles library in the rule where you need to use runfiles. E.g. in py_library:
    py_library(
        name = "my_lib",
        ...
        deps = ["@bazel_tools//tools/python/runfiles"],
        data = [
            ... # some runfiles
        ],
    )
    
  2. Import / include / source the runfiles library, as the documentation (see below) shows.
  3. Create / init the runfiles object and look up runfiles using rlocation / Rlocation.

See:


[1] this should move to @bazel_tools//tools/java/runfiles, but I never got around doing the migration)

@gkalpak
Copy link
Contributor

gkalpak commented Jun 20, 2018

Thx for the info. Unfortunately, I want to use the runfiles in Node.js, which doesn't seem to have a helper lib 😞

Regarding:

sure it would be possible, but I'm afraid we don't have capacity to do the migration, plus this would make it impossible to support older Windows versions

Just to be clear, I didn't mean make this the default behavior for Windows. But it would be great if there was a way to tell bazel that symlinks are supported (e.g. set an env var) and then it could behave the same as on linux/macOS.
(But I understand that it might not be as straight forward as flipping a switch under the hood. I have no idea about bazel internals 😇)

@laszlocsomor
Copy link
Contributor

Just to be clear, I didn't mean make this the default behavior for Windows. But it would be great if there was a way to tell bazel that symlinks are supported (e.g. set an env var) and then it could behave the same as on linux/macOS.

Sure, I agree. :) Alas, I don't know to do that, and we already have plenty of other things to do, I'm afraid I can't spend time on it, sorry :( Maybe someone else will pick it up?...

@filipesilva
Copy link

filipesilva commented Aug 17, 2018

https://github.com/bazelbuild/rules_nodejs can be used for runfile resolution, but there are problems with the manifest approach (like #5926).

I've opened an issue for the native symlink support too, at the time I hadn't seen the discussion here: #5807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) platform: windows type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

6 participants