ubuntu - CircleCI 2.0,apt-get 失败,返回 "Permission denied"

标签 ubuntu continuous-integration yaml circleci

我正在设置 CircleCI 2.0 配置,我需要包含 ubuntu 包“pdf2htmlex”,但出现以下错误:

apt-get update && apt-get install -y pdf2htmlex
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Exited with code 100

这里是 .circle/config.yml 的相关部分:

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:7.10
      - image: circleci/postgres:9.6.2

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
      - checkout
      - run:
          name: Install System Dependencies
          command: apt-get update && apt-get install -y pdf2htmlex      
      - run:
          name: save SHA to a file
          command: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install dependencies via npm
          command: npm install
      - run:
          name: Run tests
          command: npm run test
      - run: scripts/build.sh
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules
      - save_cache:
          key: v1-repo-{{ checksum ".circle-sha" }}
          paths:
            - ~/repo

谁能提出解决这个问题的方法,因为这会导致我们的一些集成测试失败?

最佳答案

您应该能够将 sudo 添加到 apt-get 安装行:

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:7.10
      - image: circleci/postgres:9.6.2

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
      - checkout
      - run:
          name: Install System Dependencies
          command: sudo apt-get update && sudo apt-get install -y pdf2htmlex      
      - run:
          name: save SHA to a file
          command: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install dependencies via npm
          command: npm install
      - run:
          name: Run tests
          command: npm run test
      - run: scripts/build.sh
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules
      - save_cache:
          key: v1-repo-{{ checksum ".circle-sha" }}
          paths:
            - ~/repo

关于ubuntu - CircleCI 2.0,apt-get 失败,返回 "Permission denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46781452/

相关文章:

java - Spring Boot结构体中应用Yml Map<String,Map<String,List<Object>>>

aws-lambda - lambda 函数内的跨堆栈引用

ubuntu - 在 Ubuntu 16.04 上安装 CUDA(未满足的依赖项)

ubuntu - 在访问 Kubernetes UI 方面需要帮助

Ruby:Linux ubuntu 上的图形用户界面 tk 不起作用

continuous-integration - 如何重试失败的测试?

database - Visual Studio 2010 自动化数据库部署

php - 无法通过 ubuntu 12 中的 CAKE PHP 连接到 MSSQL 数据库

.net - 使用 mstest,我可以针对每种支持的语言运行我的单元测试套件吗?

yaml - 在YAML属性中指定字符串值 'yes'