【问题标题】:CircleCI 2.0, apt-get failing with "Permission denied"CircleCI 2.0,apt-get 因“权限被拒绝”而失败
【发布时间】:2017-10-17 02:06:31
【问题描述】:

我正在设置 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

任何人都可以提出解决方法,因为这会导致我们的一些集成测试失败?

【问题讨论】:

    标签: ubuntu continuous-integration yaml circleci


    【解决方案1】:

    您应该可以将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
    

    【讨论】:

    • 顺便说一句,我需要为工作流程中的每个阶段进行 apt-get,因为在我进入测试阶段时我发现它丢失了。
    • 我们如何保存缓存,这样我们就不需要每次都安装 apt-get。谢谢。
    • 我也遇到了类似的问题,但是使用了 sudo,有什么建议可以解决它
    猜你喜欢
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 2022-01-22
    相关资源
    最近更新 更多