在Mac上安装Lambda容器的Delve失败。

huangapple go评论102阅读模式
英文:

Failed to install Delve for the lambda container on Mac

问题

我使用了VS Code的AWS Toolkit和SAM来创建一个基于Go的基本SAM Web应用程序(我是通过VS Code生成的)。
这是一些通用的Lambda模板代码,它从请求中读取IP并在浏览器上返回Hello <IP>

我的最终目标是在VS Code中逐行调试我的Lambda函数。
我的launch.json中似乎有一些默认配置:

{
    "configurations": [
        {
            "type": "aws-sam",
            "request": "direct-invoke",
            "name": "sunflowers:HelloWorldFunction (go1.x)",
            "invokeTarget": {
                "target": "template",
                "templatePath": "${workspaceFolder}/sunflowers/template.yaml",
                "logicalId": "HelloWorldFunction"
            },
            "lambda": {
                "payload": {},
                "environmentVariables": {},
                "runtime": "go1.x"
            }
        },
        {
            "type": "aws-sam",
            "request": "direct-invoke",
            "name": "API sunflowers:HelloWorldFunction (go1.x)",
            "invokeTarget": {
                "target": "api",
                "templatePath": "${workspaceFolder}/sunflowers/template.yaml",
                "logicalId": "HelloWorldFunction"
            },
            "api": {
                "path": "/hello",
                "httpMethod": "GET",
                "payload": {
                    "json": {}
                }
            },
            "lambda": {
                "runtime": "go1.x"
            }
        }
    ]
}

然而,当我点击“开始调试”按钮时,我得到了一个无法安装delve的错误:

2022-08-03 21:20:46 [ERROR]: log level: info
2022-08-03 21:20:47 [INFO]: Retrieving AWS endpoint data
2022-08-03 21:20:47 [INFO]: OS: Darwin arm64 21.6.0
2022-08-03 21:20:47 [INFO]: Visual Studio Code extension host:  1.69.2
2022-08-03 21:20:47 [INFO]: AWS Toolkit:  1.46.0
2022-08-03 21:20:47 [INFO]: node: 16.13.2
2022-08-03 21:20:47 [INFO]: electron: 18.3.5
2022-08-03 21:21:49 [WARN]: SAM debug: missing AWS credentials (Toolkit is not connected)
2022-08-03 21:21:50 [INFO]: autoconnect: connected: 'profile:default'
2022-08-03 21:21:50 [INFO]: Command: (not started) [/Users/varungawande/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/debuggers/delve/install-1.9.0.sh ]
2022-08-03 21:21:50 [ERROR]: Failed to cross-compile Delve debugger: Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:412:11)
    at Object.spawn (node:child_process:718:9)
    at Function.l [as spawn] (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:27:9212)
    at /Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1495
    at new Promise (<anonymous>)
    at cc.run (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1099)
    at AH (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2076:252)
    at _H (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2075:195)
    at E6.invokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:5965)
    at E6.makeAndInvokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1314)
    at E6.resolveDebugConfigurationWithSubstitutedVariables (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1202) {
  errno: -8,
  code: 'Unknown system error -8',
  syscall: 'spawn'
}
2022-08-03 21:22:27 [INFO]: Command: (not started) [/Users/varungawande/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/debuggers/delve/install-1.9.0.sh ]
2022-08-03 21:22:27 [ERROR]: Failed to cross-compile Delve debugger: Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:412:11)
    at Object.spawn (node:child_process:718:9)
    at Function.l [as spawn] (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:27:9212)
    at /Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1495
    at new Promise (<anonymous>)
    at cc.run (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1099)
    at AH (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2076:252)
    at _H (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2075:195)
    at E6.invokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:5965)
    at E6.makeAndInvokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1314)
    at E6.resolveDebugConfigurationWithSubstitutedVariables (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1202) {
  errno: -8,
  code: 'Unknown system error -8',
  syscall: 'spawn'
}
2022-08-03 21:25:49 [INFO]: telemetry: sent batch (size=5)

我的Lambda函数需要amd64架构,而我的Mac使用的是M1芯片,因此其架构是arm64。上述错误是否由于这种架构不匹配引起的?
我尝试使用Docker在本地运行Lambda,并且可以正常工作(使用sam local start-apisam local invoke),但是我不确定在使用调试器时是否会出现上述问题。

英文:

I used the VS Code AWS Toolkit and SAM to create a basic SAM web app based on Go(I VS Code generate it).
It's some generic template code for the Lambda that reads IP from request and returns a Hello &lt;IP&gt; on the browser.

My end goal is to manage to see line by line debugging on my lambda function in VS Code.
There seem to be some default configurations in my launch.json:

{
    &quot;configurations&quot;: [
        {
            &quot;type&quot;: &quot;aws-sam&quot;,
            &quot;request&quot;: &quot;direct-invoke&quot;,
            &quot;name&quot;: &quot;sunflowers:HelloWorldFunction (go1.x)&quot;,
            &quot;invokeTarget&quot;: {
                &quot;target&quot;: &quot;template&quot;,
                &quot;templatePath&quot;: &quot;${workspaceFolder}/sunflowers/template.yaml&quot;,
                &quot;logicalId&quot;: &quot;HelloWorldFunction&quot;
            },
            &quot;lambda&quot;: {
                &quot;payload&quot;: {},
                &quot;environmentVariables&quot;: {},
                &quot;runtime&quot;: &quot;go1.x&quot;
            }
        },
        {
            &quot;type&quot;: &quot;aws-sam&quot;,
            &quot;request&quot;: &quot;direct-invoke&quot;,
            &quot;name&quot;: &quot;API sunflowers:HelloWorldFunction (go1.x)&quot;,
            &quot;invokeTarget&quot;: {
                &quot;target&quot;: &quot;api&quot;,
                &quot;templatePath&quot;: &quot;${workspaceFolder}/sunflowers/template.yaml&quot;,
                &quot;logicalId&quot;: &quot;HelloWorldFunction&quot;
            },
            &quot;api&quot;: {
                &quot;path&quot;: &quot;/hello&quot;,
                &quot;httpMethod&quot;: &quot;GET&quot;,
                &quot;payload&quot;: {
                    &quot;json&quot;: {}
                }
            },
            &quot;lambda&quot;: {
                &quot;runtime&quot;: &quot;go1.x&quot;
            }
        }
    ]
}

However on clicking the "Start Debugging" button, I get that error that it can't install delve:

2022-08-03 21:20:46 [ERROR]: log level: info
2022-08-03 21:20:47 [INFO]: Retrieving AWS endpoint data
2022-08-03 21:20:47 [INFO]: OS: Darwin arm64 21.6.0
2022-08-03 21:20:47 [INFO]: Visual Studio Code extension host:  1.69.2
2022-08-03 21:20:47 [INFO]: AWS Toolkit:  1.46.0
2022-08-03 21:20:47 [INFO]: node: 16.13.2
2022-08-03 21:20:47 [INFO]: electron: 18.3.5
2022-08-03 21:21:49 [WARN]: SAM debug: missing AWS credentials (Toolkit is not connected)
2022-08-03 21:21:50 [INFO]: autoconnect: connected: &#39;profile:default&#39;
2022-08-03 21:21:50 [INFO]: Command: (not started) [/Users/varungawande/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/debuggers/delve/install-1.9.0.sh ]
2022-08-03 21:21:50 [ERROR]: Failed to cross-compile Delve debugger: Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:412:11)
    at Object.spawn (node:child_process:718:9)
    at Function.l [as spawn] (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:27:9212)
    at /Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1495
    at new Promise (&lt;anonymous&gt;)
    at cc.run (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1099)
    at AH (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2076:252)
    at _H (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2075:195)
    at E6.invokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:5965)
    at E6.makeAndInvokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1314)
    at E6.resolveDebugConfigurationWithSubstitutedVariables (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1202) {
  errno: -8,
  code: &#39;Unknown system error -8&#39;,
  syscall: &#39;spawn&#39;
}
2022-08-03 21:22:27 [INFO]: Command: (not started) [/Users/varungawande/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/debuggers/delve/install-1.9.0.sh ]
2022-08-03 21:22:27 [ERROR]: Failed to cross-compile Delve debugger: Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:412:11)
    at Object.spawn (node:child_process:718:9)
    at Function.l [as spawn] (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:27:9212)
    at /Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1495
    at new Promise (&lt;anonymous&gt;)
    at cc.run (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1099)
    at AH (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2076:252)
    at _H (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2075:195)
    at E6.invokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:5965)
    at E6.makeAndInvokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1314)
    at E6.resolveDebugConfigurationWithSubstitutedVariables (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1202) {
  errno: -8,
  code: &#39;Unknown system error -8&#39;,
  syscall: &#39;spawn&#39;
}
2022-08-03 21:25:49 [INFO]: telemetry: sent batch (size=5)

My lambda requires the architecture amd64, while my Mac has the M1 chip, so it has an architecture of arm64. Is the above error due to this architecture mismatch?
I tried running the lambda locally using docker and that worked(using sam local start-api and sam local invoke), but am not sure the above with work as smoothly when using a debugger.

答案1

得分: 2

原来这是由于VS Code的AWS Toolkit扩展中的一个错误导致的。该错误已在AWS Toolkit 1.47中修复。

英文:

Turns out this is due to a bug in AWS Toolkit extension of VS Code. It was fixed in AWS Toolkit 1.47.

huangapple
  • 本文由 发表于 2022年8月4日 00:04:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/73224424.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定