Search code examples
continuous-integrationnestjsgithub-actionsmonorepopnpm

sh: 1: nest: Permission denied in GitHub Action


For some reason the build step for my NestJS project in my GitHub Action fails for a few days now. I use Turborepo with pnpm in a monorepo and try to run the build with turbo run build. This works flawlessly on my local machine, but somehow in GitHub it fails with sh: 1: nest: Permission denied. ELIFECYCLE  Command failed with exit code 126. I'm not sure how this is possible, since I couldn't find any meaningful change I made to the code in the meantime. It just stopped working unexpectedly. I actually think it is an issue with GH Actions, since it actually works in my local Docker build as well.

Has anyone else encountered this issue with NestJS in GH Actions?

This is my action yml:

name: Test, lint and build
on: 
  push:
jobs:
  test-lint-build:
    runs-on: ubuntu-latest
    services:
      postgres:
        # Docker Hub image
        image: postgres
        # Provide the password for postgres
        env:
          POSTGRES_HOST: localhost
          POSTGRES_USER: test
          POSTGRES_PASSWORD: docker
          POSTGRES_DB: financing-database
        ports:
          # Maps tcp port 5432 on service container to the host
          - 2345:5432
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install pnpm
        uses: pnpm/[email protected]
        with:
          version: latest

      - name: Install
        run: pnpm i

      - name: Lint
        run: pnpm run lint

      - name: Test
        run: pnpm run test

      - name: Build
        run: pnpm run build
        env:
          VITE_SERVER_ENDPOINT: http://localhost:8000/api

      - name: Test financing-server (e2e)
        run: pnpm --filter @project/financing-server run test:e2e 

Solution

  • I found out what was causing the problem. I was using node-linker = hoisted to mitigate some issues the pnpm way of linking modules was causing with my jest tests. Removing this from my project suddenly made the action work again.

    I still don't know why this only broke the build recently, since I've had this option activated for some time now.