ramsey / composer-install

:gift: A GitHub Action to streamline installation of PHP dependencies with Composer.
MIT License
233 stars 32 forks source link

Cannot find composer.json #225

Closed YoSoyElCapitan closed 1 year ago

YoSoyElCapitan commented 2 years ago

Description

We are using this in github workflows with mono repo. Composer install can not find composer.json in sub-directories. Cache is empty.

Steps to reproduce

- uses: ramsey/composer-install@2.1.0
     with:
        working-directory: something
        composer-options: --prefer-dist

Expected behavior

Should find composer.json and also create cache.

Screenshots or output

[RuntimeException]
File "./composer.json" cannot be found in the current directory

Environment details

Additional context

Custom cache keys does not solve this problem.

marcosfreitas commented 2 years ago

I'm facing something like this, but my composer.json is on the root of the project:

name: Laravel E2E Tests

on:
  push:
    # Publish `main` as Docker `latest` image.
    branches: [main]

    # Publish `v1.2.3` tags as releases.
    tags:
      - v*
  pull_request:
    branches: [main]
    tags:
      - v*

  # manually run a workflow
  workflow_dispatch:

jobs:
  laravel-tests:

    strategy:
      matrix:
        os: [ubuntu-latest]
        php: [7.4]
        dependencies: [lowest, highest]
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v3

      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: mysqli, pdo_mysql, bcmath, gd

      - uses: "ramsey/composer-install@v2"
        with:
          working-directory: ".." 🐛 
          dependency-versions: "${{ matrix.dependencies }}"

...

image

marcosfreitas commented 2 years ago

✅ fixed for me. That was something wrong with the use of the attribute "working-directory". I think it could not be inside quotation marks.

Spl4shh commented 2 years ago

Hi, I have the same error but with no modification on the working director because it's the repo himself

tn3rb commented 2 years ago

Also getting this issue with a monorepo

path to composer.json in repo: tests/phpunit/composer.json

workflow:

        - name: Composer install
          uses: 'ramsey/composer-install@v2'
          with:
              composer-options: ${{ inputs.composer-options }}  --ansi
              custom-cache-key: ${{ inputs.cache-key }}-${{ steps.timestamp.outputs.hour }}
              dependency-versions: ${{ inputs.composer-dependencies }}
              working-directory: ${{ inputs.composer-path }}

output:

Run ramsey/composer-install@v2
  with:
    composer-options: --optimize-autoloader --ignore-platform-reqs  --ansi
    custom-cache-key: Linux-***-lint-2022-09-29-19
    dependency-versions: locked
    working-directory: tests/phpunit
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
Run ${GITHUB_ACTION_PATH}/bin/php_version.sh
Run ${GITHUB_ACTION_PATH}/bin/should_cache.sh ""
Run ${GITHUB_ACTION_PATH}/bin/composer_paths.sh \
  ${GITHUB_ACTION_PATH}/bin/composer_paths.sh \
    "" \
    "tests/phpunit" \
    "/usr/bin/php"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1

In ConfigCommand.php line 202:

  File "./composer.json" cannot be found in the current directory