无法 运行 以 root 身份编写脚本,但在没有它的情况下权限被拒绝

Cannot run script as root, but permission denied in process without it

我正在尝试在我的 Ubuntu 机器上安装 Mycroft AI。

如果我 运行: bash dev_setup.sh 我得到错误: fatal: Unable to create '/home/bobo/mycroft-core/.git/index.lock': Permission denied

如果我 运行 sudo bash dev_setup.sh,我会收到消息:此脚本不应 运行 作为 root 或使用 sudo。 如果您确实需要这样做,请使用 --allow-root

重新运行

如果我 运行 bash dev_setup.sh --allow-root,我会收到相同的权限被拒绝错误消息

关于如何将其发送到 运行

的任何建议

编辑:

问题的前一步:

sudo git clone https://github.com/MycroftAI/mycroft-core.git
Cloning into 'mycroft-core'...
remote: Enumerating objects: 552097, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (59/59), done.
remote: Total 552097 (delta 43), reused 64 (delta 31), pack-reused 552007
Receiving objects: 100% (552097/552097), 115.56
Resolving deltas: 100% (542625/542625), done.

执行时不需要sudo:

sudo git clone https://github.com/MycroftAI/mycroft-core.git

执行此操作时,将使用 root 权限创建目录,当尝试执行脚本时 bash dev_setup.sh 需要 root 权限,但脚本不需要这些权限,您需要删除目录并再次尝试执行 git 克隆。然后就可以执行脚本了。

# delete the directory
sudo rm -R mycroft-core
# clone again the repository
git clone https://github.com/MycroftAI/mycroft-core.git
# Move to the directory
cd mycroft-core
# Execute the script
bash dev_setup.sh