系统信息

系统信息

我有一个安装脚本,它似乎工作正常并且不会输出任何错误,但是当使用新安装的软件包之一运行命令时,我被告知我没有访问密钥文件的权限 ( /home/test/.config/configstore/bower-github.json)。

但是,当我使用以下命令安装软件包时精确的来自脚本的相同命令,但在终端中一一手动运行(在脚本之外),一切都按预期工作,没有关于权限的抱怨。

导致权限问题的脚本是什么?

系统信息

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

(我在新安装的虚拟机上分别进行了测试;结果是相同的)

脚本

#!/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'
}

答案1

您是否尝试过更改所有权..

chown test.test /home/test/.config/configstore/bower-github.json

相关内容