Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.21k stars 746 forks source link

Bicep extension on ARM (MAC m2) #12967

Open MiguelElGallo opened 8 months ago

MiguelElGallo commented 8 months ago

Does this occur consistently? Repro steps:

  1. I use the following devcontainter.json:

    
    // For format details, see https://aka.ms/devcontainer.json. For config options, see the
    // README at: https://github.com/devcontainers/templates/tree/main/src/python
    {
    "name": "Python 3",
    // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
    // "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
    "dockerFile": "Dockerfile",
    "features": {
        "ghcr.io/devcontainers/features/azure-cli:1": {},
        "ghcr.io/azure/azure-dev/azd:0.1.0": {},
        "ghcr.io/devcontainers/features/docker-in-docker:2": {},
        "ghcr.io/devcontainers/features/node": {}
        },
    
    // Features to add to the dev container. More info: https://containers.dev/features.
    // "features": {},
    
    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    "forwardPorts": [7071,9091,3000],
    
    // Configure tool-specific properties.
    "customizations": {
        "vscode": {
            // Add the IDs of extensions you want installed when the container is created.
            "extensions": [
                "ms-python.python",
                "ms-python.vscode-pylance",
                "charliermarsh.ruff",
                "ms-azuretools.vscode-docker",
                "ms-azuretools.vscode-bicep",
                "azurite.azurite",
                "ms-azuretools.vscode-azurefunctions"
    
            ],
        // Add devcontainer-specific settings.json values here, such as:
        "settings": {
            "python.defaultInterpreterPath": "/usr/local/bin/python",
            "python.linting.enabled": true,
            "python.testing.unittestEnabled": false,
            "python.testing.pytestEnabled": true,
            "[python]": {
                "editor.formatOnSave": true,
                "editor.codeActionsOnSave": {
                    "source.fixAll": true
                }
            },
            "python.formatting.provider": "black"
    
        }
    }
    },
    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "python3 -m pip install -r requirements.txt && npm install -g azure-functions-core-tools@4 --unsafe-perm true && npm install -g azurite"
    
    // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
    // "remoteUser": "root"
    }
2. Open any bicep file, and it crashes

Action: bicep.lsp-error
Error type: Error
Error Message: Connection closed

Version: 0.24.24
OS: linux
OS Release: 6.1.57-0-virt
Product: Visual Studio Code
Product Version: 1.85.1
Language: en

<details>

<summary>Call Stack</summary>

callback client.ts:270:17 callWithTelemetryAndErrorHandlingSync @microsoft/callWithTelemetryAndErrorHandling.js:68:16 Object.closed client.ts:264:7 LanguageClient.handleConnectionClosed vscode-languageclient/client.js:1164:72 LanguageClient.handleConnectionClosed vscode-languageclient/main.js:180:22 apply vscode-languageclient/client.js:1142:18 CallbackList.call [as invoke] vscode-jsonrpc/events.js:55:39 Emitter.fire vscode-jsonrpc/events.js:117:36 apply vscode-jsonrpc/connection.js:314:26 CallbackList.call [as invoke] vscode-jsonrpc/events.js:55:39 Emitter.fire vscode-jsonrpc/events.js:117:36 SocketMessageWriter.fireClose vscode-jsonrpc/messageWriter.js:42:27 Socket. vscode-jsonrpc/messageWriter.js:74:42



</details>
anthony-c-martin commented 8 months ago

@MiguelElGallo take a look at #10245.

MiguelElGallo commented 8 months ago

My docker version says: Docker version 24.0.5, build ced0996 Is this good?

MiguelElGallo commented 8 months ago

@anthony-c-martin I read #10245 : I do not use Docker Desktop, I use Rancher Desktop. I Rancher Desktop, if you go to Settings->Virtual Machine->Emulation there are 2 options:

It was in QEMU, now I changed to VZ. (They suggest something like that for Docker) Just as comment, is easily 5 times faster, but still, the moment I clicked a BICEP file , it crashed.

Any ideas? Cheers!

MiguelElGallo commented 8 months ago

In the Process monitor now I see a process called "virtual machine Service for limactl.ventura" I mention this because in #10245 , lima is mentioned many times.

MiguelElGallo commented 8 months ago

The log is:

2024-01-12T19:14:42.177Z info: Current log level: debug.
2024-01-12T19:14:42.185Z info: Acquiring dotnet runtime...
2024-01-12T19:15:48.497Z debug: Found dotnet command at '/home/vscode/.vscode-server/data/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.15~x64/dotnet'.
2024-01-12T19:15:48.498Z info: Launching Bicep language service...
2024-01-12T19:15:48.498Z debug: Found language server at '/home/vscode/.vscode-server/extensions/ms-azuretools.vscode-bicep-0.24.24/bicepLanguageServer/Bicep.LangServer.dll'.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Regex3_Scan(RegexRunner, ReadOnlySpan`1)
7:15:49 PM: Error: Connection closed
[Error - 7:15:49 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 7:15:49 PM] Connection to server got closed. Server will restart.
true
[Error - 7:15:49 PM] Bicep client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:49 PM] Server process exited with signal SIGABRT.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Regex3_Scan(RegexRunner, ReadOnlySpan`1)
7:15:50 PM: Error: Connection closed
[Error - 7:15:50 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 7:15:50 PM] Connection to server got closed. Server will restart.
true
[Error - 7:15:50 PM] Bicep client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
7:15:50 PM: Error: Pending response rejected since connection got disposed
[Error - 7:15:50 PM] Server process exited with signal SIGABRT.
2024-01-12T19:15:50.881Z error: Pending response rejected since connection got disposed
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Regex3_Scan(RegexRunner, ReadOnlySpan`1)
7:15:52 PM: Error: Connection closed
[Error - 7:15:52 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 7:15:52 PM] Connection to server got closed. Server will restart.
true
[Error - 7:15:52 PM] Bicep client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:52 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:52 PM] Server process exited with signal SIGABRT.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Regex3_Scan(RegexRunner, ReadOnlySpan`1)
7:15:53 PM: Error: Connection closed
[Error - 7:15:53 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 7:15:53 PM] Connection to server got closed. Server will restart.
true
[Error - 7:15:53 PM] Bicep client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:53 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:53 PM] Server process exited with signal SIGABRT.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Regex3_Scan(RegexRunner, ReadOnlySpan`1)
7:15:54 PM: Error: Connection closed
[Error - 7:15:54 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:54 PM] The Bicep server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 7:15:54 PM] Bicep client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:54 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 7:15:54 PM] Server process exited with signal SIGABRT.
anthony-c-martin commented 8 months ago

You could try the option recommended here: https://github.com/dotnet/runtime/issues/94909 (the DOTNET_EnableWriteXorExecute env var).

Ultimately it's going to be hard for us to support emulated architectures, because we're limited by the emulation technologies and dotnet. I've raised #13096 for us to add a disclaimer about this.