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

[BUG]vscode执行init任务失败 #399

Open
CHELO-NG opened this issue May 11, 2024 · 10 comments
Open

[BUG]vscode执行init任务失败 #399

CHELO-NG opened this issue May 11, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@CHELO-NG
Copy link
Contributor

Bug描述
当使用 vscode 的 终端>运行任务>init 进行初始化时,报错:

Pasted image 20240511100525

环境

  • OS Version: Ubuntu 22.04.4 LTS
  • CPU Arch(x86/arm): x86_64

Bug分析

zsh 无法找到 sudo 命令,导致命令运行失败。

尝试使用 bash 来直接执行初始化命令,但依然报出了相同的错误:

image

目前 init 命令:

sudo -E env PATH=$PATH bash ${workspaceFolder}/build.sh init

分析:

  1. 使用 sudo 主要是为了使用 root 权限来执行后续命令
  2. -E env PATH=$PATH 为了在切换到 root 执行命令时依然可以使用当前用户的环境配置(?)
  3. bash ${workspaceFolder}/build.sh init 使用 bash 调用构建脚本执行初始化

但是根据开发手册推荐使用的 Docker 容器,其用户已经是以 root 登录(不清楚文档中是否存在以非 root 用户开发的情况),因此尝试使用如下命令替换原始命令:

bash ${workspaceFolder}/build.sh init

经测试,此方法确实可以正常运行。

但是,不是很清楚为什么没有 sudo 命令。

请大家指正。

@CHELO-NG CHELO-NG added the bug Something isn't working label May 11, 2024
@hnwyllmm
Copy link
Collaborator

已经是root用户了,把配置中的 sudo 去掉,再重新执行吧。

@CHELO-NG
Copy link
Contributor Author

image

我修改成了这样,可以正常运行。

不知这个问题是否为普遍问题,需不需要把修改提交一个pr?

@hnwyllmm
Copy link
Collaborator

普通用户需要加sudo,所以仅仅去掉不是解决方案。

@hnwyllmm
Copy link
Collaborator

可以把deps/3rd下面的项目直接安装在本地,而不是系统目录,这样就都不需要sudo了,我更倾向于使用这种普适的方案。

@CHELO-NG
Copy link
Contributor Author

不好意思,忘了说这个开发环境是使用的 docker/Dockerfile 部署的。

想办法解决“无法在 docker 开发容器中使用 sudo 命令”的问题似乎是更好的方案。

但是我不太确定无法使用 sudo 命令是不是因为我的配置问题。

我在尝试使用最新的 Dockerfile 重新构建镜像,但是最新的 Dockerfile 存在问题,在第15行的末尾缺少 '\'。

@hnwyllmm
Copy link
Collaborator

感谢提醒。docker中确实使用的就是root用户,不需要加sudo命令。

关于第15行缺少''的问题,可以帮忙提交一个PR吗?

@hnwyllmm
Copy link
Collaborator

对了,docker环境已经执行过 build.sh init,使用docker开发时,不需要再执行 build.sh init了。

@CHELO-NG
Copy link
Contributor Author

感谢提醒。docker中确实使用的就是root用户,不需要加sudo命令。

关于第15行缺少''的问题,可以帮忙提交一个PR吗?

好的

@CHELO-NG
Copy link
Contributor Author

提交了#400

@CHELO-NG
Copy link
Contributor Author

对了,docker环境已经执行过 build.sh init,使用docker开发时,不需要再执行 build.sh init了。

确实,在开发过程中也不需要频繁的执行 init 操作,.vscode/tasks.json 也没有修改的必要。

这样的话,这个 issue 应该可以关闭了,感谢您的解答,辛苦了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants