I have an installation script which appears to work fine and doesn't output any errors, but when running a command with one of the newly installed packages, I'm told I don't have permission to access a key file (/home/test/.config/configstore/bower-github.json).

However, when I install the packages using the exact same commands from the script, but run manually in the terminal one by one (outside of the script), everything works as expected, with no complaints about permissions.

What is it about the script that is causing a permission issue?

System info

Linux test 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Commands to run script

bash adapt.sh
sudo bash adapt.sh

(I've tried both in separate tests on fresh VM installs; the result was the same)




# Print description
echo "Adapt installation for Ubuntu 18.04 LTS (Bionic Beaver)"
echo "### Supported until April 2023 ###"
sleep 2
echo "The Adapt authoring tool, CLI and dependencies will be installed."
sleep 2
echo -n "Would you like to continue? [y/N] "
read input
if [[ $input == "y" || $input == "Y" ]]; then
    echo "Creating and moving to new Adapt directory ..."
    sleep 2
    mkdir ~/adapt
    cd ~/adapt
    touch LOG.txt
    echo "Updating software package repos ..."
    sudo apt-get update >> /dev/null 2>&1
    echo "Installing Git ..."
    sudo apt-get -y install git-all >> $LOG 2>&1
    $(which curl >> /dev/null 2>&1)
    if [ $? != 0 ]; then
        sudo apt-get -y install curl >> $LOG 2>&1
    echo "Installing Node.js v12.x (LTS) ..."
    curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - >> $LOG 2>&1
    sudo apt-get -y install nodejs >> $LOG 2>&1
    echo "Installing Grunt ..."
    sudo npm install -g grunt-cli >> $LOG 2>&1
    echo "Installing the Adapt CLI ..."
    sudo npm install -g adapt-cli >> $LOG 2>&1
    echo "Installing MongoDB and starting mongod service ..."
    wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - >> $LOG 2>&1
    sudo touch /etc/apt/sources.list.d/mongodb-org-4.2.list
    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee -a /etc/apt/sources.list.d/mongodb-org-4.2.list >> /dev/null 2>&1
    sudo apt-get update >> /dev/null 2>&1
    sudo apt-get -y install mongodb-org >> $LOG 2>&1
        sudo service mongod start >> $LOG 2>&1
    echo "Installing the Adapt authoring tool ..."
    git clone https://github.com/adaptlearning/adapt_authoring.git >> $LOG 2>&1
    cd adapt_authoring
    sudo npm install --production >> $LOG 2>&1
    sudo node install
    echo "Exiting..."

echo "Refer to 'LOG.txt' for more information."


test@test:~/adapt$ adapt create course
                throw err;

Error: EACCES: permission denied, open '/home/test/.config/configstore/bower-github.json'
You don't have access to this file.

    at Object.openSync (fs.js:458:3)
    at Object.readFileSync (fs.js:360:35)
    at Configstore.get (/usr/lib/node_modules/adapt-cli/node_modules/bower/lib/node_modules/configstore/index.js:35:26)
    at new Configstore (/usr/lib/node_modules/adapt-cli/node_modules/bower/lib/node_modules/configstore/index.js:28:45)
    at readCachedConfig (/usr/lib/node_modules/adapt-cli/node_modules/bower/lib/config.js:19:23)
    at defaultConfig (/usr/lib/node_modules/adapt-cli/node_modules/bower/lib/config.js:11:12)
    at Object.<anonymous> (/usr/lib/node_modules/adapt-cli/node_modules/bower/lib/index.js:16:32)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/home/test/.config/configstore/bower-github.json'
  • 1
    What is adapt create course? What does that have to do with your script? You said you get an error from the script, so why are you showing an error from some other command?
    – terdon
    Jun 12 '20 at 12:58
  • 1
    Did the file get created during a sudo ... invocation, such that the file is now owned by root and inaccessible to your non-root user?
    – Jeff Schaller
    Jun 12 '20 at 13:04
  • @terdon I didn't say I got an error from the script. I got the error when trying to use a program installed with the script. The program in question is adapt-cli. This installs fine. But only when installed via the script the command adapt [...] shows the permission error. After carrying out some more research, I believe it could be something to do with the way I've run the script; possibly I should have used ./adapt.sh instead.
    – squire
    Jun 12 '20 at 13:25

have you tried changing the ownership ..

chown test.test /home/test/.config/configstore/bower-github.json
  • I've marked this as the answer as my own answer/workaround involves the same: - chown -R $USER:$GROUP ~/.config chown -R $USER:$GROUP ~/.npm
    – squire
    Jun 15 '20 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.