恢复CircleCi作业中的缓存时权限被拒绝

问题描述 投票:1回答:1

[每当我执行工作时,他们总是花大约40来下载并安装libreoffice。我将把它存储到缓存中并恢复缓存以在下一个作业中重复使用。

      - restore_cache:
          key: cache-libre-6.3-b             # Restore libreoffice
      - run:
          name: install libreoffice 6.3
          command: |
            if [[ ! -d /opt/libreoffice6.3/ ]]; then
                # download & install the .deb
                mkdir -p /tmp/libreoffice
                l=download.tar.gz
                cd /tmp/libreoffice
                  wget -O $l https://download.documentfoundation.org/libreoffice/stable/6.3.3/deb/x86_64/LibreOffice_6.3.3_Linux_x86-64_deb.tar.gz
                  tar -xvf $l
                  d=`ls -td */ | head -n1`
                  cd $d/DEBS/
                  sudo dpkg -i *.deb
                cd -

                # install dependencies required when run :soffice binary  ref. https://github.com/microsoft/vscode/issues/13089
                sudo apt update
                sudo apt install -y libxinerama1 libgtk2.0-0 libxss-dev libgconf-2-4 libasound2

            fi
            # make :libreoffice softlink to libreoffice binary 6.3
            sudo ln -s /opt/libreoffice6.3/program/soffice /usr/bin/libreoffice
            sudo chmod -R 777 /opt/libreoffice6.3/
      - save_cache:
          key: cache-libre-6.3-b
          paths:
            # Save cache libreoffice
            - /opt/libreoffice6.3/
            - /home/circleci/cache-libre

当我再次重新运行作业时,无法恢复缓存。我在下面拒绝了某些许可:

Found a cache from build 7593 at cache-libre-6.3-b
Size: 271 MB
Cached paths:
  * /opt/libreoffice6.3
  * /home/circleci/cache-libre

Downloading cache archive...
Validating cache...

Unarchiving cache...

Failed to unarchive cache

Error untarring cache: Error extracting tarball /tmp/cache785237819 : tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/CREDITS.fodt: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/LICENSE: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/LICENSE.html: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/NOTICE: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/help: Cannot mkdir: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/help/a11y-toggle.js: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdir: Permission denied tar: opt/libreoffice6.3/help/default.css: Cannot open: No such file or directory tar: opt/libreoffice6.3: Cannot mkdi: exit status 2

我该如何解决。

linux bash caching circleci circleci-2.0
1个回答
0
投票

最近这也发生在我身上。鉴于我有很多构建版本,在该密钥可能是断断续续的之前就使用该密钥来保存和还原该高速缓存,这不太可能是直接原因。但是,我谨提一提,以防万一它对人们有所帮助。

我以前一直在尝试使用working_directory命令来尝试使用persist-to-workspaceattach_workspace,并认为这可能引起了问题。

可能引起错误的序列:

  • Build A:

    1. 设置工作目录working_directory: ~/tmp
    2. 使用键X保存缓存
  • Build B:

    1. 默认工作目录(未使用working_directory命令)
    2. 尝试使用相同的键X(但工作目录不同)恢复缓存
    3. Error untarring cache: Error extracting tarball

解决该问题的解决方案只是更改缓存密钥。例如从v1前缀到v2。这样可以避免尝试还原为尝试将工作目录tmp还原到其他工作目录而创建的缓存。现在使用一个新的。

© www.soinside.com 2019 - 2024. All rights reserved.