You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Path length limits: a lot of tools (e.g. the C# compiler IIRC) are still very limited. I don't think this has come up yet for me in rule-writing specifically but maybe it could be a factor (we do set --output_user_root to C:\tmp to generally mitigate this.)
Something that would be interesting is any advice for making the best of unsandboxed execution. For example, we're able to vendor the C# compiler via an external package, but we rely on the system-wide .NET framework installation. My assumption (we haven't got to the point of cache sharing yet) is that these unsandboxed/unvendored resources won't contribute to the digests used in caching. This could lead (naturally) to non-repeatable builds in a way that could be dangerous with cache-sharing.
My guess at what I'll have to do is find some proxy to include as an input from outside the sandbox (e.g. there are files/registry keys that indicate the specific .NET framework release number) and "hope for the best". Any kind of insight here would be really helpful. If there's specific things we should document as rule authors on this topic that'd be good to know.
I'd like to see a section on dealing with runfiles:
- which environment variables to discover location of the runfiles manifest
- avoid using runfiles for things which could just be inputs to the action
- whether to use runfiles manifest on non-Windows platforms
- how to patch tools that expect to read from the filesystem to do a lookup
through the manifest file instead (including helpers in many languages)
- how this applies in tests as well that rely on $TEST_SRCDIR
On Thu, Dec 14, 2017 at 7:57 AM Jacob Parker ***@***.***> wrote:
Some things I've hit:
- Windows command line length limits. Many(?) tools use the "response
file" idiom which (usually?) maps to Bazel's param files (via ctx.Args)
directly (example PR:
https://github.com/bazelbuild/rules_dotnet/pull/47/files )
- ctx.actions.run should be used when possible (vs. the deprecated
ctx.action) to avoid bash
- Bash/etc. on windows should be avoided if possible (general perf,
difficulty with consistent environment, weird edge cases like #4013
<#4013>)
- Path length limits: a lot of tools (e.g. the C# compiler IIRC) are
still very limited. I don't think this has come up yet for me in
rule-writing specifically but maybe it could be a factor (we do set
--output_user_root to C:\tmp to generally mitigate this.)
Something that would be interesting is any advice for making the best of
unsandboxed execution. For example, we're able to vendor the C# compiler
via an external package, but we rely on the system-wide .NET framework
installation. My assumption (we haven't got to the point of cache sharing
yet) is that these unsandboxed/unvendored resources won't contribute to the
digests used in caching. This could lead (naturally) to non-repeatable
builds in a way that could be dangerous with cache-sharing.
My guess at what I'll have to do is find some proxy to include as an input
from outside the sandbox (e.g. there are files/registry keys that indicate
the specific .NET framework release number) and "hope for the best". Any
kind of insight here would be really helpful. If there's specific things we
should document as rule authors on this topic that'd be good to know.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3889 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5IzY-v-vk9WqIJAwP9wd9nh9VVlEEks5tAUVNgaJpZM4P1DsG>
.
Something that would be interesting is any advice for making the best of unsandboxed execution. For example, we're able to vendor the C# compiler via an external package, but we rely on the system-wide .NET framework installation. My assumption (we haven't got to the point of cache sharing yet) is that these unsandboxed/unvendored resources won't contribute to the digests used in caching. This could lead (naturally) to non-repeatable builds in a way that could be dangerous with cache-sharing.
Frankly I have no good answer at the moment. (For the record, we don't know about the feasibility of sandboxing on Windows.)
My guess at what I'll have to do is find some proxy to include as an input from outside the sandbox (e.g. there are files/registry keys that indicate the specific .NET framework release number) and "hope for the best".
That'd be one option. Another is to create a local repository for the .NET framework and write the .NET rules such that their actions depend on that local repository.
Update: sorry for having dropped the ball on this issue. I never submitted any docs. @j3parker and @alexeagle , do you think it's still worthwhile to publish best practices for writing platform-aware Skylark rules?
Just to clarify, if I run Bazel in PowerShell, and then build a genrule, Bazel will automatically find my Git Bash (or similar) installation and run that to build the target?
Just to clarify, if I run Bazel in PowerShell, and then build a genrule, Bazel will automatically find my Git Bash (or similar) installation and run that to build the target?
Activity
laszlocsomor commentedon Dec 14, 2017
Bumping to P1 -- we committed to doing this work in Q4'2017.
laszlocsomor commentedon Dec 14, 2017
I plan to work on this next week.
j3parker commentedon Dec 14, 2017
Some things I've hit:
ctx.Args) directly (example PR: https://github.com/bazelbuild/rules_dotnet/pull/47/files )ctx.actions.runshould be used when possible (vs. the deprecatedctx.action) to avoid bash--output_user_roottoC:\tmpto generally mitigate this.)Something that would be interesting is any advice for making the best of unsandboxed execution. For example, we're able to vendor the C# compiler via an external package, but we rely on the system-wide .NET framework installation. My assumption (we haven't got to the point of cache sharing yet) is that these unsandboxed/unvendored resources won't contribute to the digests used in caching. This could lead (naturally) to non-repeatable builds in a way that could be dangerous with cache-sharing.
My guess at what I'll have to do is find some proxy to include as an input from outside the sandbox (e.g. there are files/registry keys that indicate the specific .NET framework release number) and "hope for the best". Any kind of insight here would be really helpful. If there's specific things we should document as rule authors on this topic that'd be good to know.
alexeagle commentedon Dec 14, 2017
laszlocsomor commentedon Dec 18, 2017
Thank you @j3parker and @alexeagle , these are insightful and valuable ideas and questions. I'll incorporate them / their answers in the doc.
@j3parker :
Frankly I have no good answer at the moment. (For the record, we don't know about the feasibility of sandboxing on Windows.)
That'd be one option. Another is to create a local repository for the .NET framework and write the .NET rules such that their actions depend on that local repository.
@alexeagle :
Thanks for mentioning runfiles, I'll write a section on that. There's also #4279.
laszlocsomor commentedon May 16, 2018
Update: sorry for having dropped the ball on this issue. I never submitted any docs. @j3parker and @alexeagle , do you think it's still worthwhile to publish best practices for writing platform-aware Skylark rules?
alexeagle commentedon May 17, 2018
13 remaining items
rongjiecomputer commentedon Mar 22, 2019
Bazel works in any Windows shell (cmd, powershell and bash). It is just that Bazel will internally call bash for genrule, sh_test, sh_binary etc.
njlr commentedon Mar 22, 2019
OK, that sounds like what I was hoping for! 🙂
Just to clarify, if I run Bazel in PowerShell, and then build a
genrule, Bazel will automatically find my Git Bash (or similar) installation and run that to build the target?rongjiecomputer commentedon Mar 22, 2019
It is better to set
BAZEL_SHenv var to absolute path ofbash.exethat you want to use (regardless of what shell you use).laszlocsomor commentedon Mar 25, 2019
@njlr :
Correct. As @rongjiecomputer says, better to set
BAZEL_SH.I advise against using Git Bash as
BAZEL_SH. See #5751Windows, docs: tips and tricks to write rules
Windows, docs: tips and tricks to write rules
Windows, docs: tips and tricks to write rules
Windows, docs: tips and tricks to write rules
Windows, docs: tips and tricks to write rules
meteorcloudy commentedon May 12, 2020
I'm closing this one because @laszlocsomor has done an excellent job in https://docs.bazel.build/versions/master/skylark/windows_tips.html
Please file new issue or PR if you think anything else should be added in that guide.