Skip to content

Composer unable to apply patches #62

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

Closed
joz-cti opened this issue Aug 19, 2021 · 21 comments
Closed

Composer unable to apply patches #62

joz-cti opened this issue Aug 19, 2021 · 21 comments
Labels
help wanted Extra attention is needed

Comments

@joz-cti
Copy link

joz-cti commented Aug 19, 2021

This github action is unable to apply composer patches, the specific add on I am using is - https://github.com/cweagans/composer-patches
It is strange that if I use "composer install" instead of this package then composer can apply the patches.
The add on requires "patch" to be installed on the server, I can confirm this was installed on the Ubuntu OS.
Are there permission restriction on what this action can do? Perhaps it cannot write/update to the the file system?

@g105b
Copy link
Member

g105b commented Aug 24, 2021

Hi @joz-cti,

This isn't something I'm familiar with, but I'll look into it for you as soon as I can.

Any follow up information here would be useful, but I'll pick it up as soon as I get some time.

Cheers,
Greg.

@dschmidtadv
Copy link

composer-patches

I am facing the same issue.

@g105b
Copy link
Member

g105b commented Sep 5, 2022

Hi @joz-cti

I'm following up on this as the issue is still unresolved. Please could you help me by showing me the output of your failing workflow? I can't see any reason why this wouldn't work out of the box, as Ubuntu does indeed have diff and patch installed by default.

Thanks,
Greg.

@joz-cti
Copy link
Author

joz-cti commented Sep 5, 2022 via email

@viktor-borysiuk
Copy link

viktor-borysiuk commented Oct 6, 2022

Hi Greg,

I have the same issue with applying compose patches. I can share you the output message, perhaps will help you

patch '-p1' --no-backup-if-mismatch -d '<package_name>' < '<path_to_file_patch.patch'
sh: patch: not found

@g105b
Copy link
Member

g105b commented Oct 6, 2022

Interesting - it looks like this is run within sh rather than bash, and the patch command isn't available by default. I'll look into this on the example-composer repository and see if I can replicate, and once it's replicable it's fixable. Thanks for your input @viktor-borysiuk

@g105b g105b added the help wanted Extra attention is needed label Nov 9, 2022
@g105b
Copy link
Member

g105b commented Nov 9, 2022

I've added the help wanted label because I'm not sure how to fix this myself.

@pingevt
Copy link

pingevt commented Dec 12, 2022

@g105b - First, I'm no expert on Github actions, and could be completely off base, so take it for what its worth. But this is the rabbit trail I've gone down for looking into this.

So after that rabbit trail... I think adding patch at least to your docker image in the RUN apk command is the first place to start. However, I'm not sure how to test this locally.

Also, I guess I would also ask, why not use a composer docker image?

@pingevt
Copy link

pingevt commented Dec 12, 2022

@g105b

OK - I forked 2 of your repos, and I think I have this working.

Simply put, in your php-build.bash file in php-actions/php-build, I changed:

RUN apk add --update --no-cache zip git bash openssh"
to
RUN apk add --update --no-cache bash coreutils git make openssh patch unzip zip"

I added in a few others from composer's docker file.

I want to keep looking into this on my site to make sure it really is working.

@g105b
Copy link
Member

g105b commented Dec 13, 2022

Oh that looks a lot simpler than I thought. I'll make that change on php-build, unless you want to raise a PR for it, then we can test it for real on https://github.com/php-actions/example-composer

@pingevt
Copy link

pingevt commented Dec 13, 2022

Just added a PR. I worked on it a little more yesterday and is working for my case.

@g105b
Copy link
Member

g105b commented Dec 14, 2022

Will update this ticket later with the outcome of testing.

@g105b
Copy link
Member

g105b commented Dec 20, 2022

Hi - this looks to be working now on a test branch. Please can you give it a run by using this step in your workflow file:

      - name: Install dependencies
        uses: php-actions/composer@bluecadet

@g105b
Copy link
Member

g105b commented Dec 20, 2022

The bluecadet branch is using the PR raised by @pingevt.

Thanks!

@pingevt
Copy link

pingevt commented Jan 5, 2023

@g105b Finally got around to looking into this... At first pass it looks like it is working for my use case.

@g105b g105b closed this as completed in da5a2cb Jan 5, 2023
@shawnachieve
Copy link

Has this issue been fixed? I've tried using both the v6 and the bluecadet builds, but still get the same errors reported in this ticket when applying patches.

Here is my workflow:

jobs:
  update-composer-lock:
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout"
        uses: actions/checkout@v3
      - name: "Update lock file"
        uses: php-actions/composer@bluecadet
        env:
          COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
        with:
          php_version: "8.0"
          php_extensions: bcmath gd
          ssh_key: ${{ secrets.SSH_KEY }}
          ssh_key_pub: ${{ secrets.SSH_KEY_PUB }}
          command: update
          args: -vvv --with-all-dependencies
      - uses: actions/upload-artifact@v3
        with:
          name: debug-output
          path: output.log

The error response I get is:

 - Applying patches for drupal/core
    https://git.drupalcode.org/project/drupal/-/merge_requests/71.diff (Support entities that are neither content nor config entities[node/3042467])
Executing command (CWD): patch '-p2' --no-backup-if-mismatch -d 'web/core' < '/tmp/63efb2b950e20.patch'
patch '-p2' --no-backup-if-mismatch -d 'web/core' < '/tmp/63efb2b950e20.patch'
sh: patch: not found

   Could not apply patch! Skipping

@g105b
Copy link
Member

g105b commented Feb 18, 2023

Hey @pingevt I wondered if you could take a look at @shawnachieve's message and compare your issue with theirs?

It may be that there is a different issue here, in which case we can re-open this and I can try to replicate with the supplied yml.

@pingevt
Copy link

pingevt commented Feb 18, 2023

Looks like its still the same error: sh: patch: not found So thats a bit interesting.

@shawnachieve could you provide some more information? Your composer file or Is this in a public repo we could look at?

@g105b
Copy link
Member

g105b commented Feb 19, 2023

The thing I notice from the error message is that it's being generated from a part of the script that's running in sh rather than bash... I'm just making a note to myself here for tomorrow when I look at it.

@lukaszpilka
Copy link

Why is this issue closed, is it resolved? I tried to use "patch" in my composer.json and I am facing the same error.

patch '-p2' --no-backup-if-mismatch -d 'docroot/core' < '/tmp/641d4245c3285.patch'
sh: patch: not found

@liangshen-hds
Copy link

I got the same error "sh: patch: not found" with php-actions/composer@bluecadet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Development

No branches or pull requests

8 participants