Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: Unable to locate the git repository in the given path #1948

Closed
4 tasks done
TomOMara opened this issue Feb 21, 2024 · 4 comments
Closed
4 tasks done

[BUG] Error: Unable to locate the git repository in the given path #1948

TomOMara opened this issue Feb 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@TomOMara
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Hi, i'm encountering the following error when running against a node 18.14.0 or above. The error does not occur at version 18.13.0 or below.

> Run tj-actions/changed-files@v42
/usr/bin/docker exec <hash> sh -c "cat /etc/*release | grep ^ID"
> changed-files
  Error: Unable to locate the git repository in the given path: /__w/my-repo/my-repo.
   Please run actions/checkout before this action (Make sure the 'path' input is correct).
   If you intend to use Github's REST API note that only pull_request* events are supported. Current event is "push".

To Reproduce

With the following workflow file:

name: Test Action

on:
  push:
  workflow_dispatch:

jobs:
  build-ota:
    container: public.ecr.aws/docker/library/node:18.14.0
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Check files changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v42
        with:
          files_yaml: |
            src:
              - src/**
              - '**/*.tsx'

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

I'd expect there to be no error thrown using any version of node 18. There is no error when using node:18.13.0 or lower

Relevant log output

Happy logs (using node 18.13.0): 

##[debug]Evaluating condition for step: 'Check files changed'
##[debug]Evaluating: (success() && !github.event.inputs.platform)
##[debug]Evaluating And:
##[debug]..Evaluating success:
##[debug]..=> true
##[debug]..Evaluating Not:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating Index:
##[debug]..........Evaluating github:
##[debug]..........=> Object
##[debug]..........Evaluating String:
##[debug]..........=> 'event'
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'inputs'
##[debug]......=> null
##[debug]....=> null
##[debug]..=> true
##[debug]=> true
##[debug]Expanded: (true && !null)
##[debug]Result: true
##[debug]Starting: Check files changed
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: github.api_url
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'api_url'
##[debug]=> 'https://api.github.com'
##[debug]Result: 'https://api.github.com'
##[debug]Loading env
Run tj-actions/changed-files@v42
/usr/bin/docker exec  73a982e4c7c25670edb3b098c959ed1e307020011f8fb4c594ebd8dd53877e6e sh -c "cat /etc/*release | grep ^ID"
##[debug]ID=debian
##[debug]Running JavaScript Action with default external tool: node20
::group::changed-files
changed-files
::group::changed-files-yaml-src
changed-files-yaml-src
##[debug]modified_keys: ["src"]
##[debug]changed_keys: ["src"]
##[debug]Node Action run completed with exit code 0


Error logs (using node 18.14.0 or above)


##[debug]Evaluating condition for step: 'Check files changed'
##[debug]Evaluating: (success() && !github.event.inputs.platform)
##[debug]Evaluating And:
##[debug]..Evaluating success:
##[debug]..=> true
##[debug]..Evaluating Not:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating Index:
##[debug]..........Evaluating github:
##[debug]..........=> Object
##[debug]..........Evaluating String:
##[debug]..........=> 'event'
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'inputs'
##[debug]......=> null
##[debug]....=> null
##[debug]..=> true
##[debug]=> true
##[debug]Expanded: (true && !null)
##[debug]Result: true
##[debug]Starting: Check files changed
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: github.api_url
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'api_url'
##[debug]=> 'https://api.github.com'
##[debug]Result: 'https://api.github.com'
##[debug]Loading env
Run tj-actions/changed-files@v42
/usr/bin/docker exec  6a5309ff5f1153eb8d9d0b987b0fe38554cadbf46aa83899d0b16e85177bc3ad sh -c "cat /etc/*release | grep ^ID"
##[debug]ID=debian
##[debug]Running JavaScript Action with default external tool: node20
::group::changed-files
changed-files
  ##[debug]Env: {
  ##[debug]  "PATH": "/__t/eas-cli/7.3.0/x64/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  ##[debug]  "HOSTNAME": "6a5309ff5f11",
  ##[debug]  "HOME": "/github/home",
  ##[debug]  "GITHUB_ACTIONS": "true",
  ##[debug]  "CI": "true",
  ##[debug]  "NODE_VERSION": "18.14.0",
  ##[debug]  "YARN_VERSION": "1.22.19",
  ##[debug]  "EXPO_TOKEN": "***",
  ##[debug]  "INPUT_FILES_YAML": "src:\n  - src/**\n  - '**/*.tsx'\n",
  ##[debug]  "INPUT_SEPARATOR": " ",
  ##[debug]  "INPUT_INCLUDE_ALL_OLD_NEW_RENAMED_FILES": "false",
  ##[debug]  "INPUT_OLD_NEW_SEPARATOR": ",",
  ##[debug]  "INPUT_OLD_NEW_FILES_SEPARATOR": " ",
  ##[debug]  "INPUT_FILES_FROM_SOURCE_FILE": "",
  ##[debug]  "INPUT_FILES_FROM_SOURCE_FILE_SEPARATOR": "\n",
  ##[debug]  "INPUT_FILES": "",
  ##[debug]  "INPUT_FILES_SEPARATOR": "\n",
  ##[debug]  "INPUT_FILES_YAML_FROM_SOURCE_FILE": "",
  ##[debug]  "INPUT_FILES_YAML_FROM_SOURCE_FILE_SEPARATOR": "\n",
  ##[debug]  "INPUT_FILES_IGNORE_YAML": "",
  ##[debug]  "INPUT_FILES_IGNORE_YAML_FROM_SOURCE_FILE": "",
  ##[debug]  "INPUT_FILES_IGNORE_YAML_FROM_SOURCE_FILE_SEPARATOR": "\n",
  ##[debug]  "INPUT_FILES_IGNORE": "",
  ##[debug]  "INPUT_FILES_IGNORE_SEPARATOR": "\n",
  ##[debug]  "INPUT_FILES_IGNORE_FROM_SOURCE_FILE": "",
  ##[debug]  "INPUT_FILES_IGNORE_FROM_SOURCE_FILE_SEPARATOR": "\n",
  ##[debug]  "INPUT_SHA": "",
  ##[debug]  "INPUT_BASE_SHA": "",
  ##[debug]  "INPUT_SINCE": "",
  ##[debug]  "INPUT_UNTIL": "",
  ##[debug]  "INPUT_PATH": ".",
  ##[debug]  "INPUT_QUOTEPATH": "true",
  ##[debug]  "INPUT_DIFF_RELATIVE": "true",
  ##[debug]  "INPUT_DIR_NAMES": "false",
  ##[debug]  "INPUT_DIR_NAMES_MAX_DEPTH": "",
  ##[debug]  "INPUT_DIR_NAMES_EXCLUDE_CURRENT_DIR": "false",
  ##[debug]  "INPUT_DIR_NAMES_INCLUDE_FILES": "",
  ##[debug]  "INPUT_DIR_NAMES_INCLUDE_FILES_SEPARATOR": "\n",
  ##[debug]  "INPUT_DIR_NAMES_DELETED_FILES_INCLUDE_ONLY_DELETED_DIRS": "false",
  ##[debug]  "INPUT_JSON": "false",
  ##[debug]  "INPUT_ESCAPE_JSON": "true",
  ##[debug]  "INPUT_SAFE_OUTPUT": "true",
  ##[debug]  "INPUT_FETCH_DEPTH": "50",
  ##[debug]  "INPUT_SKIP_INITIAL_FETCH": "false",
  ##[debug]  "INPUT_FETCH_ADDITIONAL_SUBMODULE_HISTORY": "false",
  ##[debug]  "INPUT_SINCE_LAST_REMOTE_COMMIT": "false",
  ##[debug]  "INPUT_WRITE_OUTPUT_FILES": "false",
  ##[debug]  "INPUT_OUTPUT_DIR": ".github/outputs",
  ##[debug]  "eventName": "push",
  ##[debug]  "sha": "1ea505a0b4f81ea2918beb9855c88c932014c599",
  ##[debug]  "ref": "refs/heads/ci-test-fix-1",
  ##[debug]  "workflow": "Test Action",
  ##[debug]  "action": "changed-files-yaml",
  ##[debug]  "actor": "****",
  ##[debug]  "job": "build-ota",
  ##[debug]  "runNumber": 217,
  ##[debug]  "runId": 7989125576,
  ##[debug]  "apiUrl": "https://api.github.com",
  ##[debug]  "serverUrl": "https://github.com",
  ##[debug]  "graphqlUrl": "https://api.github.com/graphql"
  ##[debug]}
  ##[debug]Working directory: /__w/my-repo/my-repo
  /usr/bin/git rev-parse --is-inside-work-tree
  fatal: detected dubious ownership in repository at '/__w/my-repo/my-repo'
  To add an exception for this directory, call:
  
  	git config --global --add safe.directory /__w/my-repo/my-repo
  ##[debug]The current working directory is not inside a git repository: /__w/my-repo/my-repo
  ##[debug]Has git directory: false
  ##[debug]Input file patterns: 
  ##[debug]
  ##[debug]File patterns: 
  ##[debug]Yaml file patterns: {"src":["src/**","**/*.tsx"]}
  Error: Unable to locate the git repository in the given path: /__w/my-repo/my-repo.
   Please run actions/checkout before this action (Make sure the 'path' input is correct).
   If you intend to use Github's REST API note that only pull_request* events are supported. Current event is "push".
  ##[debug]Node Action run completed with exit code 1
  ##[debug]Finishing: Check files changed

Has all relevant logs been included?

  • I've included all relevant logs

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@TomOMara TomOMara added the bug Something isn't working label Feb 21, 2024
@tj-actions-bot
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Feb 21, 2024

HI @TomOMara from the logs it appears the following error occurred

  /usr/bin/git rev-parse --is-inside-work-tree
  fatal: detected dubious ownership in repository at '/__w/my-repo/my-repo'
  To add an exception for this directory, call:
  
  	git config --global --add safe.directory /__w/my-repo/my-repo

@TomOMara
Copy link
Author

Hey @jackton1 - thanks for replying so quick. If I'm interpreting it correctly - there is an ownership issue on the cloned git directory from the previous checkout action, and that is causing a mis-read at changed-files's level.

Assuming others will run into the same issue, the snipped below (extended example in above report) might work for them, though I wonder if it'd be smoother to include that step in the cleaned-files action internals. You're deffo better placed to make that call!

name: Test Action

on:
  push:
  workflow_dispatch:

jobs:
  build-ota:
    container: public.ecr.aws/docker/library/node:18.14.0
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      
      # ensure changed-files can read repo files from git
      - name: Configure Git Safe Directory
        run: git config --global --add safe.directory /__w/my-repo/my-repo

      - name: Check files changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v42
        with:
          files_yaml: |
            src:
              - src/**
              - '**/*.tsx'

@jackton1
Copy link
Member

jackton1 commented Feb 21, 2024

Hi @TomOMara, thanks for the suggestion one thing to point out is this is done by the checkout action set-safe-directory input and would be out of the scope of this action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants