Repository navigation
Description
🐞 bug report
Affected Package
This issue is related to running Bazel on Windows.
Is this a regression?
N/A
Description
I checked out Angular and did a fresh yarn install. Once that was done, I tried running one of the package/examples, in this case it was my own example package (for my PR at #29755), which runs fine on the CI.
Once I run my example using yarn bazel run //packages/examples/router/activated-route:devserver, I get the error I mentioned below.
To resolve this, all I had to do was open PowerShell and execute the following command:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
When I now try and run yarn bazel run //packages/examples/router/activated-route:devserver, everything works fine! :)
As this unblocked me, I used this aproach and decided to see if anyone on twitter had a way to solve this.
The friendly @alexeagle replied to my tweet asking if I had an Github issue. I didn't, but now I do 😄 !
🔬 Minimal Reproduction
Just run the master on Windows 10 with the default Execution Policy (Resitricted) and run any example mini-app ( ensure to empty your bazel directory with cache etc). If you want to execute the command I've been pasting (yarn bazel run //packages/examples/router/activated-route:devserver), you'll need to run my branch for this PR: #29755
🔥 Exception or Error
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: error loading package '': Encountered error while reading extension file 'package.bzl': no such package '@npm_bazel_karma//': copy_repository failed:
STDOUT:
STDERR:
File C:\users\frederik\_bazel_frederik\p5aerkcd\external\npm_bazel_karma\_copy.ps1 cannot be loaded because running
scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
ERROR: error loading package '': Encountered error while reading extension file 'package.bzl': no such package '@npm_bazel_karma//': copy_repository failed:
STDOUT:
STDERR:
File C:\users\frederik\_bazel_frederik\p5aerkcd\external\npm_bazel_karma\_copy.ps1 cannot be loaded because running
scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
INFO: Elapsed time: 54.276s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.🌍 Your Environment
Angular Version:
N/A
Anything else relevant?
So I'm running on Windows 10, My Execution-Policy is set to its default value.
If any other environmental information is needed, feel free to reach out.
Activity
frederikprijck commentedon Apr 8, 2019
I got a feeling it's an issue on my end. I mean, the ExecutionPolicy is doing what it's expected, right? Not allowing bazel to execute the script ...
However, I wanted to create this issue anyway, but feel free to close it if it's expected behavior.
meteorcloudy commentedon Apr 9, 2019
@frederikprijck I guess this is WAI.
I am able to
yarn bazel run packages/examples/common:devserveron Windows withfrederikprijck commentedon Apr 9, 2019
@meteorcloudy Yes, I guess the reason it's working for you is because you've set the ExecutionPolicy to
Bypassfor theLocalMachinescope. Setting it toUnrestrictedalso works for me.Do you recommend people to update their ExecutionPolicy to either Bypass or
Unrestricted? I'm not familiar with PowerShell, but it doesn't sound like a setting you wanna have.meteorcloudy commentedon Apr 9, 2019
I'm not very familiar with powershell, either. I think users should only be required to set
ExecutionPolicywhen their default setting doesn't work. @alexeagle What do you think it the best way to document this?frederikprijck commentedon Apr 9, 2019
Important to note that:
I'm not familiar with Bazel, I guess it needs this setting. However it would be good if it could be avoided or configured to only set it for the bazel process (if that's even possible).
meteorcloudy commentedon Apr 9, 2019
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6#set-a-different-execution-policy-for-one-session
Looks like we can run
powershell.exewith-ExecutionPolicy Unrestrictedoption.alexeagle commentedon Apr 16, 2019
Is there a way we can run code without the user having to modify a setting? Using .bat instead of powershell? We should always treat this kind of bad user ergonomics as a bug (I imagine many devs wouldn't have rights to change that kind of policy on their machine anyway)
@gregmagolan has a plan to remove the need for powershell in this case I believe.
gregmagolan commentedon Apr 23, 2019
Finally got around to this. bazel-contrib/rules_nodejs#717 removes the powershell dep & used a
.batfile insteadmeteorcloudy commentedon Apr 23, 2019
There is another powershell dependency coming from rules_webtesting:
https://github.com/bazelbuild/rules_webtesting/blob/master/web/internal/extract.bat
But I'm not sure there's any equivalent command in batch.
@gregmagolan
Remove yarn_install & npm_install dependency on Windows powershell
Initial Toolchain Support
angular-automatic-lock-bot commentedon Sep 15, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.