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?
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
bash adapt.sh
sudo bash adapt.sh
(I've tried both in separate tests on fresh VM installs; the result was the same)
#!/bin/bash
LOG=~/adapt/LOG.txt
# Print description
echo
echo "Adapt installation for Ubuntu 18.04 LTS (Bionic Beaver)"
echo "### Supported until April 2023 ###"
sleep 2
echo
echo "The Adapt authoring tool, CLI and dependencies will be installed."
sleep 2
echo -n "Would you like to continue? [y/N] "
read input
echo
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
fi
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
else
echo "Exiting..."
fi
echo "Refer to 'LOG.txt' for more information."
echo
test@test:~/adapt$ adapt create course
/usr/lib/node_modules/adapt-cli/node_modules/bower/lib/node_modules/configstore/index.js:54
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'
}