11

I am in the process of a setting up a CircleCI 2.0 configuration and I am needing to include the ubuntu package 'pdf2htmlex', but I am being given the following error:

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

Here is the relevant portions of the .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

Can anyone suggest a way around this, since this is causing some of our integration tests to fail?

Andre M
  • 6,649
  • 7
  • 52
  • 93

1 Answers1

15

You should be able to add sudo to theapt-get install line:

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
Derek Brown
  • 4,232
  • 4
  • 27
  • 44
  • BTW will I need to apt-get for each phase in the workflow, since I am finding it missing by the time I get to the testing phase. – Andre M Oct 17 '17 at 02:30
  • 4
    How can we save cache so we don't need apt-get install each time. thanks. – hqt Nov 15 '17 at 10:29
  • 1
    I have runned into a similar problem but with a sudo in place, any suggestions how can I get rid of it – pannu Dec 27 '18 at 11:40