Skip to content

Use a different temp directory each time for downloading remote patches #654

@James-Oakley

Description

@James-Oakley

Verification

  • I have updated Composer to the most recent stable release (composer self-update)
  • I have updated Composer Patches to the most recent stable release (composer update cweagans/composer-patches)
  • I am using one of the supported PHP versions (8.0+)
  • I have searched existing issues and discussions for my idea.

Is your feature request related to a problem?

I'm enjoying exploring the 2.0.0 version. Thank you.

One snag I hit was when I tried to run composer pd on the second project on the same server. I got an error that composer couldn’t create a file in /tmp/composer-patches. This directory had been created when I applied patches on the first project I'd worked on. It was therefore owned by the owner for that first project's directory, and had permissions 644. My second project, running on a different Linux account, therefore could not create the directory (it already existed) and so could not write to it.

I got around this by creating a custom .user.ini file for my php cli to pick up, that contained sys_temp_dir=/home/{username}/tmp

Describe your proposed solution(s)

Instead of attempting to write patches into /tmp/composer-patches, use a folder like /tmp/composer-patches-`date +%s` . It would need cleaning up afterwards.

Describe alternatives

In the extra > composer-patches section within composer.json, allow a new entry: "tmp_dir": "{directory}"

This may not work when composer.json is checked into version control. If the project's temporary patching directory was hard-wired into composer.json, the same directory would be used in any environment. That could cause problems, assuming there was no way to resolve ~ within php, because an absolute path /home/user1/tmp would not work if someone is developing a project in /home/user2.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, options, or other additions.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions