Search code examples
bashroot

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


I am attempting to install Mycroft AI on my Ubuntu machine.

If I run: bash dev_setup.sh I get the error: fatal: Unable to create '/home/bobo/mycroft-core/.git/index.lock': Permission denied

If I run sudo bash dev_setup.sh, I receive the message: This script should not be run as root or with sudo. If you really need to for this, rerun with --allow-root

If I run bash dev_setup.sh --allow-root, I receive the same Permission denied error message

Any suggestions on how to get this to run

Edit:

Step previous to the problem:

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.

Solution

  • You don't need use sudo when execute:

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

    When you do this, the directory is created with root's permissions and when try to execute the script bash dev_setup.sh requires root's permissions, but the script doesn't need those privileges, you need delete the directory and try again to execute git clone. Then you can execute the script.

    # 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