Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions - No Such File or Directory on Any Run Step

I am trying to test out Github Actions for a small web project. I have two projects in the repository, and I want to create a deployment script for only the web client.

The repository looks like this:

root
|
|-src
|  |-API
|  |
|  |-WebClient
|
|-docs

I want to run scripts in the WebClient directory. When I try to cd into ./src/webclient, I get the error no such file or directory

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Setup Node.js environment
        uses: actions/[email protected]
        
      - name: Open Web Client Directory
        run: |
          ls -la
          cd ./src/webclient
          ls -la
          
      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
          ls -la

The output for the "Open Web Client Directory" step:

total 28
drwxr-xr-x 5 runner docker 4096 Oct 17 18:05 .
drwxr-xr-x 3 runner docker 4096 Oct 17 18:05 ..
drwxr-xr-x 8 runner docker 4096 Oct 17 18:05 .git
drwxr-xr-x 3 runner docker 4096 Oct 17 18:05 .github
-rw-r--r-- 1 runner docker 6215 Oct 17 18:05 .gitignore
drwxr-xr-x 4 runner docker 4096 Oct 17 18:05 src
/home/runner/work/_temp/43164e53-98ec-41c2-8773-72e94c3453e5.sh: line 2: cd: ./src/webclient: No such file or directory
Error: Process completed with exit code 1.

It looks to be successfully doing the ls -la command, but fails to find the directory ./src/webclient.

Is there something obvious that I am missing? I have tried changing the command to cd src/webclient, and it fails also. This works on two different local machines, one ubuntu and one MacOS.

like image 628
jlat96 Avatar asked Oct 17 '20 18:10

jlat96


Video Answer


3 Answers

I had an issue where a step was failing with the following, no matter how I configured it:

Error: No such file or directory

Turns out this was because I had not checked out the repository in a previous step!

If you are accessing files from the repo, you need to perform a checkout first:

steps:
  - uses: actions/checkout@v2
like image 176
sdgluck Avatar answered Oct 17 '22 21:10

sdgluck


Try this:

- name: Open Web Client Directory
  working-directory: src/webclient
  run: |
    ls -la
like image 20
Tymur Lysenko Avatar answered Oct 17 '22 22:10

Tymur Lysenko


According to your logs, this seems to be due to case sensitivity: you show the repository to contain src/WebClient (camel cased!), but then you try to cd src/webclient (lowercase).

On macOS, this would work because the filesystem is by default case insensitive; not sure why it works on your Ubuntu system, unless you use something like tab completion, which does the casing for you.

To check what you have in your subdirectories, you can run find src instead of ls -la to see the whole directory tree in src.

like image 2
Benjamin W. Avatar answered Oct 17 '22 20:10

Benjamin W.