microsoft / vscode-azurefunctions

Azure Functions extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions
MIT License
291 stars 132 forks source link

Can't run debugger script on VS Code with M2 Mac #3605

Open FaresKi opened 1 year ago

FaresKi commented 1 year ago

VS Code Version: 1.76.0 (Universal) OS Version: 13.2 (22D49) Azure Functions Extension Version: v1.10.3 Steps to Reproduce:

  1. Have an Apple Silicon and install a rosetta terminal following the steps proposed by the Azure Functions team here.
  2. Create a function locally using the func cli.
  3. Add a breakpoint and run the "Attach to Python Functions" task to debug your function locally.
  4. You should expect it to run normally

However, I'm running into what I believe are pure VSCode issues and not necessarily related to the extensions (even though I have created an issue here and there, just in case).

Here's one of the tasks in the task.json:

{
   "type":"func",
   "command":"host start",
   "problemMatcher":"$func-python-watch",
   "isBackground":true
}

which starts locally all azure function core tools. When I run the same command normally on my rosetta terminal (aka the one running x86_64 architecture software), I have no problem.

When I run the same command using the debugger task, here is the error that is brought up:

*  Executing task: func host start 

arch: posix_spawnp: zsh: Bad CPU type in executable

 *  The terminal process "/usr/bin/arch '-x86_64', 'zsh', '-c', 'func host start'" failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it. 

Here is some additional information about my settings.json:

{
   "terminal.integrated.profiles.linux":{
      "bash":{
         "path":"bash",
         "icon":"terminal-bash"
      },
      "zsh":{
         "path":"zsh"
      },
      "fish":{
         "path":"fish"
      },
      "tmux":{
         "path":"tmux",
         "icon":"terminal-tmux"
      },
      "pwsh":{
         "path":"pwsh",
         "icon":"terminal-powershell"
      }
   },
   "terminal.integrated.profiles.osx":{
      "rosetta":{
         "path":"arch",
         "args":[
            "-x86_64",
            "zsh",
            "-l"
         ],
         "overrideName":true
      }
   },
   "terminal.integrated.defaultProfile.osx":"rosetta"
}

I don't understand where the error comes from. The terminal that vscode is using to run the command shouldn't have the "bad cpu type in executable" error because it's already running rosetta...

Am I missing something?

TIA!

MicroFish91 commented 1 year ago

There's a known issue with ARM processors and running the python extension at the moment. The external issue can be tracked here: https://github.com/Azure/azure-functions-python-worker/issues/915

FaresKi commented 1 year ago

Just to be clear. I can run the func cli on my terminal. I just can't debug.

jyotirmay123 commented 1 year ago

I have the same issue, but in my case, it shows below error as if I am running it in arm64 arch, but in normal instance, I am running it in rosetta osx profile with x86_64 arch enabled in .zshrc with func pointing to i386 build.

[2023-07-11T15:23:42.098Z] Failed to initialize worker provider for: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.5198/workers/python
[2023-07-11T15:23:42.098Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2023-07-11T15:23:42.420Z] Failed to initialize worker provider for: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.5198/workers/python
[2023-07-11T15:23:42.420Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2023-07-11T15:23:42.557Z] A host error has occurred during startup operation '43fc90c6-c79c-4544-8fd9-b3b607f11ad4'.
[2023-07-11T15:23:42.557Z] Microsoft.Azure.WebJobs.Script: Did not find functions with language [python].
[2023-07-11T15:23:42.562Z] Failed to stop host instance '99f0775f-e3c1-466e-857d-31593eda2b07'.
[2023-07-11T15:23:42.562Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')