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

Unable to unlink - Permission denied #783

Closed
NickStees opened this issue Apr 16, 2021 · 8 comments · Fixed by dfds/infrastructure-blueprints#26
Closed

Unable to unlink - Permission denied #783

NickStees opened this issue Apr 16, 2021 · 8 comments · Fixed by dfds/infrastructure-blueprints#26

Comments

@NickStees
Copy link

Subject of the issue

I am trying to automate composer updates, using a scheduled action to run 'Composer updates' and then open a new pull request from master for review. But I always get some permission denied errors.

2021-04-16_9-54-38

Steps to reproduce

runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: php-actions/composer@v2
        with:
          command: update drupal/core-recommended
          dev: yes
          args: --ignore-platform-reqs --with-dependencies
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
            token: ${{ secrets.NICKS_PAT }}
            commit-message: Update dependencies
            title: Update dependencies
            delete-branch: false
            body: |
              - Dependency updates

              Auto-generated by [create-pull-request][1]

              [1]: https://github.com/peter-evans/create-pull-request
            branch: update-dependencies
            base: master
@NickStees
Copy link
Author

Seems like it could be a file permission error? https://stackoverflow.com/questions/11774397/git-push-error-unable-to-unlink-old-permission-denied/26950991 Do I maybe have to run a CHMOD between the checkout and the Pull Request steps?

I am on windows but I use a WSL2 Linux sub-system to do most development. So I could be an edge case and why the other examples don't have these problems?

@peter-evans
Copy link
Owner

Hi @NickStees

It looks like a file or directory permission issue, but I've not seen this before. I think it's unrelated to the action itself and probably something that would also be reproducible if the repository was checked out locally. My advice would be to reproduce it locally and then try some of the suggestions in that Stackoverflow question. You might need to commit file/directory permission changes back to the repository to fix it.

You could also try using a windows runner on the off-chance that makes a difference.

runs-on: windows-latest

@orozcoadrian
Copy link

I'm getting a similar error. I'm following this example: https://github.com/lilt/lilt-java/blob/master/.github/workflows/openapi.yml
Can't tell what's different. In my case the actual error is due to uncommitted files in the working tree.

@peter-evans
Copy link
Owner

@orozcoadrian It sounds like a different issue to me. Please could you make a new issue and provide more details such as the exact workflow you are running and ideally a link to actions log if it's a public repository.

@ougni
Copy link

ougni commented Apr 29, 2021

I'm getting a similar error. I'm following this example: https://github.com/lilt/lilt-java/blob/master/.github/workflows/openapi.yml
Can't tell what's different. In my case the actual error is due to uncommitted files in the working tree.

I'm having a similar issue, my workflow just unzips a folder and tries to commit the unzipped files to the main

 warning: unable to unlink 'release/Test/.DS_Store': Permission denied
 warning: unable to unlink 'release/Test/test.txt': Permission denied
 warning: unable to unlink 'release/__MACOSX/Test/._.DS_Store': Permission denied
 HEAD is now at 1315813 zip with similar structure as solutions files
 /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --unshallow origin create-pull-request/patch:refs/remotes/origin/create-pull-request/patch
 fatal: couldn't find remote ref create-pull-request/patch
 Pull request branch 'create-pull-request/patch' does not exist yet.
 /usr/bin/git checkout --progress -B create-pull-request/patch 60feda2d-f81a-46de-9acb-ed508987ba14
 error: The following untracked working tree files would be overwritten by checkout:
 	release/Test/.DS_Store
 	release/Test/test.txt
 	release/__MACOSX/Test/._.DS_Store
 Please move or remove them before you switch branches.
 Aborting
 Error: The process '/usr/bin/git' failed with exit code 1

@peter-evans
Copy link
Owner

@ougni It looks like a permissions issue with one or more of your repository directories. See this answer: https://stackoverflow.com/questions/11774397/git-push-error-unable-to-unlink-old-permission-denied/26950991

Try running sudo chmod -R g+w on the directories that don't have the correct permissions and then push the file mode changes to git to fix it in the default branch.

@MohamedElashri
Copy link

I had this problem recently and adding sudo chown -R $USER:$USER . step solved the problem

@Jawman5070
Copy link

Jawman5070 commented Sep 1, 2022

Had this issue as well.

In our scenario, we were downloading strings.xml files from a translations service. For the files that already existed and were only being modified, there were no issues. However, there were some new files that were added that were contained in completely new folders that previously did not exist. I'm no expert, but after several attempts, my suspicion was that those newly created folders, did not inherit any of the permissions that existing folders would have.

If we added those files (blank) so that they already existed before running there worker, there were no issues. (But we didn't want to have to pre-emptively add a bunch of empty files).

sudo chmod -R g+w did not work.

sudo chmod 777 worked (but probably too high)

sudo chown -R $USER:$USER . worked (what we're going with)

@peter-evans peter-evans changed the title Permission denied after Resetting base branch Unable to unlink - Permission denied Dec 13, 2022
@peter-evans peter-evans pinned this issue Dec 13, 2022
avnes added a commit to dfds/infrastructure-blueprints that referenced this issue Feb 2, 2024
lucaspopp-wbd added a commit to istreamlabs/go-sdk that referenced this issue Jun 13, 2024
Generating the SDK is failing, due to [permissions errors on generated
files](https://github.com/istreamlabs/go-sdk/actions/runs/9504248321).
Seems to be
peter-evans/create-pull-request#783.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants