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

func.ps1 is not digitally signed. You cannot run this script on the current system. #1821

Closed
ejizba opened this issue Feb 12, 2020 · 11 comments
Assignees

Comments

@ejizba
Copy link
Contributor

ejizba commented Feb 12, 2020

originally filed by @hdd42 in microsoft/vscode-azurefunctions#1888

Hi, I'm trying to run/test my function locally through vs code. I've installed azure function core tools@3 via npm the function I'm trying to test is a timer function.

Both hitting F5 to start debug mode or func host start from terminal failing and getting this error :

func.ps1 cannot be loaded. The file C:\Program Files\nodejs\func.ps1 is not
digitally signed. You cannot run this script on the current system.

looks like it complains about PowerShells Execution_Policies . I've removed azure function core tools and re-install it via choco install azure-functions-core-tools and host is starting without any problems. (since choco is modifying PowerShells Execution_Policies that works. )

I was wondering is there any way to fix this issue without choco (or not modifying PowerShells Execution_Policies) because per company policy I'm not allow to change PowerShells Execution_Policies

Windows 10,
VS Code
1.42.0 ,
Node 12.4

Thanks.

@ejizba
Copy link
Contributor Author

ejizba commented Feb 12, 2020

Also related to microsoft/vscode-azurefunctions#1678. It seems like this is a v3 only problem, but not entirely sure.

@ahmelsayed
Copy link
Contributor

That file, as well as func.cmd, are created by npm itself. I'm not sure how much control we can have over these files, but we could check if there is a way to sign them.

@jasonuithol
Copy link

I was getting a related error message "Running scripts is disabled on this system" and sure enough the execution policy was set to restricted. It happened when, in VSCODE, I pressed F5 to kick off a build & serve.

It was working fine, then I switched my default terminal shell from gitbash to Powershell and it stopped working and gave that error. I switched back and it was fine again.

@fabiocav fabiocav added this to the Triaged milestone Feb 13, 2020
@fabiocav
Copy link
Member

Flagging this as triaged so we can investigate whether there's anything we can do to sign that file.

@DubiWork
Copy link

This is a working workaround:
Run this command as an administrator in PS-
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine

the meaning and understanding this is all here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

@jeroenhabets
Copy link

FYI: This hit me as well after migrating from Core Tools v2 using Chocolatey to Core Tools v3 using NPM (as Chocolatey was lagging too much).

@TroyWitthoeft
Copy link

TroyWitthoeft commented Mar 11, 2020

This just bit me too. Brand new install of VS Code, trying to get my first Azure Function working. I've seen it get some of my new dev's too. Let's get it fixed!

Anyone getting started with setting up an Azure Functions Core Tools environment has two gotchas

  1. Install via chocolatey - Choco should support 64 bit install of cli #693
  2. Install via npm - func.ps1 is not digitally signed. You cannot run this script on the current system. #1821

In our org, I've seen new devs get bit by both. It really slows us down during onboarding.

@jeroenhabets
Copy link

@fabiocav Can you please increase the priority of this? Until this is fixed Microsoft is basically asking users to disable their security to get Azure functions core tools to work :(

@ankitkumarr
Copy link
Contributor

As Ahmed said earlier, this seems to be an issue in the npm cli itself -- npm/cli#470.

One workaround suggested there is to delete func.ps1 file (in this case - C:\Program Files\nodejs\func.ps1), which will make func.cmd the default to run. Note: I haven't tried this yet.

Other tools, such as typescript CLI also encountered this issue -- microsoft/TypeScript#35606

If this isn't fixed soon, maybe as a temporary fix, we could add code in our post install script to delete .ps1 that is created on install, if that's possible.

@TroyWitthoeft
Copy link

@ankitkumarr Thanks. Took the conversation upstream to the npm/cli team on issue 470.

@soninaren
Copy link
Member

Closing this one since we don't have any action item on use. This is caused by npm. Here is the related issue: npm/cli#470.

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants