You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode远程调试树莓派pigpio程序需sudo权限问题

远程调试树莓派C++程序时pigpio权限问题求助

问题场景

我在Win10系统上使用VSCode远程调试无头树莓派中的C程序:仅使用基础C代码时调试配置正常,但调用pigpio操作IO时需要sudo权限。手动通过SSH登录树莓派,使用sudo运行程序可正常工作;但通过IDE调试时,会弹出如下权限不足提示:

initCheckPermitted:
+---------------------------------------------------------+
|Sorry, you don't have permission to run this program. |
|Try running as root, e.g. precede the command with sudo. |
+---------------------------------------------------------+

尝试方案及遇到的问题

我用于连接的用户拥有sudo权限,尝试在launch.json中给gdb命令前添加sudo,但未生效。随后我在/home/aaronl/lawnmower/src目录下创建了remoteDebug脚本,并将其配置到launch.json的miDebuggerPath中,但终端显示launch.json似乎未被使用,仍直接调用/usr/bin/gdb,终端输出如下:

Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-tpotth2h.twr" 1>"/tmp/Microsoft-MIEngine-Out-iz5mi0ud.r3l"

相关文件内容

File: launch.json

{"version": "0.2.0","configurations": [{"name": "C/C++ Runner: Debug Session","type": "cppdbg","request": "launch","args": [],"stopAtEntry": false,"externalConsole": false,"cwd": "/home/aaronl/lawnmower/src","program": "/home/aaronl/lawnmower/src/build/Debug/outDebug","MIMode": "gdb","miDebuggerPath": "remoteDebug","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}]}

File: remoteDebug

sudo /usr/bin/gdb "$@"

内容的提问来源于stack exchange,提问作者Aaron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 01:17:45