clue / phar-composer

Simple phar creation for every PHP project managed via Composer
https://clue.engineering/2019/introducing-phar-composer
MIT License
855 stars 78 forks source link

Unable to rename temporary phar archive when using Vagrant #116

Closed nxu closed 2 years ago

nxu commented 3 years ago

Hey

first of all, thank you for phar-composer, I love it and I've been using it for years.

Now i updated it to 1.2.0 to support composer 2 and I have an issue I simply can not seem to solve. I tried it on different computers with different php versions (7.3 and 8.0):

PHP Warning:  rename(create-project.phar.1982369873.phar,create-project.phar): Text file busy in phar:///home/vagrant/code/phar-composer.phar/src/Clue/PharComposer/Phar/PharComposer.php on line 226

Warning: rename(create-project.phar.1982369873.phar,create-project.phar): Text file busy in phar:///home/vagrant/code/phar-composer.phar/src/Clue/PharComposer/Phar/PharComposer.php on line 226

  [UnexpectedValueException]
  Unable to rename temporary phar archive to "create-project.phar"

build [project] [target]

After this, the temporary phar file works fine and I can also rename it manually. It looks like phar-composer doesn't close the handle to the file before trying to rename it.

Can you please help me with debugging?

clue commented 2 years ago

@nXu Thanks for reporting, this shouldn't have happened!

Unfortunately, I can not reproduce the problem you're seeing locally and it looks like you're the first to run into this issue. Can you provide instructions on how to reproduce this?

It looks like this might be related to using a shared folder in Vagrant? Can you try executing this in a different directory? Shared folders and slow network mounted drives could be a potential problem here if the writing is performed in the background and temporarily blocks the rename command. If this is the case, introducing some optional delays or fsync() calls might help. I'm happy to accept PRs to address this!

As much as I'd love to work on this myself, there are currently no immediate plans to build this from my end (no demand at the moment and more important outstanding issues currently). If you need this for a commercial project and you want to help sponsor this feature, feel free to reach out and I'm happy to take a look.

clue commented 2 years ago

This has now been resolved by a combination of #128, #129, and #130. I'll make sure to get this version shipped asap :shipit:

I hope this helps! :+1: If so, consider supporting this project, for example by becoming a sponsor ❤️