linux - 在 CircleCi 作业中恢复缓存时权限被拒绝
问题描述
每当我的工作运行时,他们总是需要大约 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
我该如何解决这个问题。
解决方案
这也发生在我最近。鉴于我有很多构建使用该密钥保存和恢复该缓存,然后它可能是间歇性的,这不太可能是直接原因;但是,我会提到这一点,以防它碰巧帮助人们。
我以前一直在使用该working_directory
命令来尝试使用persist-to-workspace
andattach_workspace
并认为这可能会导致问题。
可能导致错误的序列:
建个:
- 设置工作目录
working_directory: ~/tmp
- 使用键 X 保存缓存
- 设置工作目录
构建 B:
- 默认工作目录(未使用
working_directory
命令) - 尝试使用相同的键 X(但不同的工作目录)恢复缓存
Error untarring cache: Error extracting tarball
- 默认工作目录(未使用
修复它的解决方案只是更改缓存键。比如从v1
前缀到v2
。这避免了尝试恢复为tmp
要尝试将工作目录恢复到不同工作目录的缓存。它现在使用一个新鲜的。
推荐阅读
- list - 执行批量反向、批量交换和随机访问的高效数据结构
- entity-framework - 将 c++/cli 实体映射到表(实体框架)
- php - 我的 API 请求无缘无故地使用了 25 个请求
- java - getAllEntriesByKey 导致错误:Vector 中的对象类型未知或不受支持
- javascript - ES6 合并两个 FileList,更新一个 input.files 元素
- .htaccess - URL 路由/重写
- ios - 使用新属性扩展 UIView
- swift - 在 Swift 中将 BOM 写入流式传输
- php - 检查谁在服务器中进行了更改
- ios - 在 Xcode 10 升级后运行 createIPA 任务