Machine executor still running apt when commands execute

For over a year now I’ve had a job that looks like the following:

version: 2
jobs:
  my-job:
    working_directory: ~/foo
    machine: true
    steps:
      - checkout
      - run:
          command: |
            sudo apt update -qq
            sudo apt install -y <stuff I want to install>

Fairly recently, these jobs have all been failing with the following error:

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
Exited with code 100

I am about to update that job to start with while sudo fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ; do sleep 1; done or something similar, but this behavior is strange enough I figured it was worth a post here. It seems that the instance fires up and then, what, runs apt update on its own? Does it upgrade things as well? Either way, it feels like the commands shouldn’t execute until the instance is completely setup, and having apt still running implies that the instance is not completely setup. Thoughts?

Search for this error on the forum - this has come up before here. I believe I created a machine instance to replicate the issue, but at that time failed to do so.

I think I would use a loop and sleep also, good idea.

Indeed, I see some posts, but no solutions (just more workarounds). The general feeling I get from those posts is that the machine executor doesn’t get much love, which is unfortunate. I’ll add the sleep workaround, but I don’t consider that a solution. I think CircleCI needs some image tweaks for their machine executor.

Hi Kyle. I think we have an internal bug report on this, I know support has done some research on it before. Let me go confirm that and get one created if not.

1 Like

This will be fixed as part of the new image which also updates linux. I don’t have an exact timeline for this, I recommend watching https://discuss.circleci.com/c/announcements

For now, the sleep workaround is the best option.

Great to hear, thanks for looking into it, @drazisil :slight_smile: .

1 Like

@kyrofa Actually, I’m being told it’s avail now, just not the default: ubuntu-1604:20190301-01

https://circleci.com/docs/2.0/configuration-reference/#machine

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.