Having fork: Resource temporarily unavailable when running commands on macOs

I’m having the following on most commands I run on a project that uses macOS executor:

/tmp/.bash_env-5d0bf651706ea2000853edbb-0-build: fork: Resource temporarily unavailable

I am pretty sure this is causing multiple slow downs on my jobs. Is that a known issue? any way to fix it?

The commands are pretty basic, I’m just using the circleci/node orb to install Node.js and Yarn.

1 Like

This is still an issue, a single echo is taking 1:30.

Hello @JCM

Could you share more info about the issue you are experiencing? Could you share your config file?You may also wish to open a ticket with support so we may investigate your project individually.

Hi @KyleTryon

Thanks for answering. This is an excerpt of the config file:

version: 2.1
executors:
  node:
    docker:
      - image: circleci/node:latest
orbs:
  node: circleci/node@1.0.1
  yarn:
    executors:
      ios:
        parameters:
          xcode-version:
            type: string
            default: 10.2.1
        macos:
          xcode: << parameters.xcode-version >>
        shell: /bin/bash --login -o pipefail
    commands:
      restore-cache:
        parameters:
          cache-key-prefix:
            description: Prefix to use for the cache key.
            default: 'v1-yarn-cache'
            type: string
        steps:
          - restore_cache:
              keys:
                - '<< parameters.cache-key-prefix >>-{{ arch }}-{{ .Branch }}-{{ .Revision }}'
                - '<< parameters.cache-key-prefix >>-{{ arch }}-{{ .Branch }}-'
                - '<< parameters.cache-key-prefix >>-{{ arch }}-'
      save-cache:
        parameters:
          cache-key-prefix:
            description: Prefix to use for the cache key.
            default: 'v1-yarn-cache'
            type: string
          cache-dir:
            description: Dir to yarn cache
            default: '~/.yarn/cache'
            type: string
        steps:
          - save_cache:
              key: << parameters.cache-key-prefix >>-{{ arch }}-{{ .Branch }}-{{ .Revision }}
              paths:
                - << parameters.cache-dir >>
      exec:
        parameters:
          args:
            type: string
            default: ''
          cwd:
            type: string
            default: '.'
          command:
            type: string
        steps:
          - run: yarn << parameters.command >> << parameters.args >> --cwd=<< parameters.cwd >>
    jobs:
      install-and-test:
        parameters:
          # Common parameters for general customization
          should-checkout:
            description: >
              Boolean for whether or not to checkout as a first step.
            type: boolean
            default: false
          should-attach-workspace:
            description: >
              Boolean for whether or not to attach to an existing workspace.
            type: boolean
            default: true
          should-persist-workspace:
            description: >
              Boolean for whether or not to persist to workspace.
            type: boolean
            default: true
          workspace-root:
            description: >
              Workspace root path that is either an absolute path or a path relative
              to the working directory.
            type: string
            default: ~/project
          before:
            type: steps
            default: []
          after:
            type: steps
            default: []
          # Specific
          cache-dir:
            description: Folder to use for yarn cache
            default: ~/.cache/yarn
            type: string
          e:
            type: executor
            default: ios
        executor: << parameters.e >>
        steps:
          # Setup
          - when:
              condition: << parameters.should-checkout >>
              steps:
                - checkout
          - when:
              condition: << parameters.should-attach-workspace >>
              steps:
                - attach_workspace:
                    at: << parameters.workspace-root >>
          - steps: << parameters.before >>
          - run: yarn config set cache-folder << parameters.cache-dir >>
          - restore-cache
          - exec:
              command: install
              args: '--frozen-lockfile'
          - save-cache:
              cache-dir: << parameters.cache-dir >>
          - exec:
              command: test
          - when:
              condition: << parameters.should-persist-workspace >>
              steps:
                - persist_to_workspace:
                    root: << parameters.workspace-root >>
                    paths:
                      - .
          - steps: << parameters.after >>

workflows:
  version: 2
  main:
    jobs:
      - yarn/install-and-test:
          name: install-and-test
          before:
            - restore_cache:
                keys:
                  - v1-homebrew-{{ .Branch }}
                  - v1-homebrew-
            - run: brew install gnupg coreutils
            - save_cache:
                key: v1-homebrew-{{ .Branch }}
                paths:
                  - /usr/local/Homebrew
            - node/install:
                version: '12.4.0'
            - node/install-yarn
            # Remove node installation artifacts
            - run: rm -rf *.txt *.sig *.tar.gz
            - run: echo "I will take a really long time to finish"
            - run: top -l 2

The issue starts appearing after the node/install-yarn step. I just added the top step to see if the yarn command from the node orb is creating some dangling processes, but I’m still waiting for the build to get there.

The message that keeps appearing is this one:

^D^D/tmp/.bash_env-5d10d6f32cffde0008c4dc34-0-build: fork: Resource temporarily unavailable

Screens:
image

Details about the environment:

  VM 'esxi-0e6332e3-a059-4d86-ae42-c37fba603ed6'
  CIRCLE_WORKFLOW_ID=fce9b403-f37d-4a6a-9724-63b0c36f80d9
  CIRCLE_WORKFLOW_JOB_ID=0773e1e8-4d4f-40aa-a945-4ea03952513e
  CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS=b2b9fdb9-d314-4b53-b8f8-925c7afae2c0
  CIRCLE_WORKFLOW_WORKSPACE_ID=fce9b403-f37d-4a6a-9724-63b0c36f80d9

In case I need to open a support ticket, I will be able to do so in a few hours.

Hello @JCM,

Yes please do open a support ticket I think we may need to get a bigger picture of the issue here. We’d be glad to help you 1:1

1 Like

Hi @KyleTryon,

I’m having the same issue when attempting an installation using yarn on mac OS.
You can see the disparity between the reported execution time and the time displayed by the logs in the attached screenshot. My job essentially just runs yarn install after doing some additional environment setup.

Just wanted to followup on this thread since a recent support request came in referencing this error. The root cause of the problem was the Orb being utilized was setting the path for yarn, when it didn’t need to be:

This was addressed in the above and should no longer be an issue if you are utilizing the Orb. However if you are encountering this error on macOS and not using the orb, check to see if you are specifically setting a path for yarn bin. If so, try removing that line and see if you continue to have this error message.

Hope that clears everything up!