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 install on vboxfs #107

Closed
alexgit2k opened this issue Aug 7, 2019 · 33 comments · Fixed by #155
Closed

Unable to install on vboxfs #107

alexgit2k opened this issue Aug 7, 2019 · 33 comments · Fixed by #155
Assignees
Milestone

Comments

@alexgit2k
Copy link

The error has already been reported at #98, but the assumption that it is a permission / UID issue is wrong.

When installing under xfs it works without problems:

mkdir /tmp/ocramius
cd /tmp/ocramius
composer require ocramius/package-versions -vvv

But when installing under vboxfs (Virtualbox, Windows) it fails:

mkdir /home/vboxfs/ocramius
cd /home/vboxfs/ocramius
composer require ocramius/package-versions -vvv

The error-message ist:

  - Installing ocramius/package-versions (1.5.1): Downloading https://api.github.com/repos/Ocramius/PackageVersions/zipball/1d32342b8c1eb27353c8887c366147b4c2da673c
Downloading (connecting...)
Following redirect (2) https://codeload.github.com/Ocramius/PackageVersions/legacy.zip/1d32342b8c1eb27353c8887c366147b4c2da673c
Downloading https://codeload.github.com/Ocramius/PackageVersions/legacy.zip/1d32342b8c1eb27353c8887c366147b4c2da673c
Downloading (100%)
 Extracting archiveExecuting command (CWD): unzip -qq  '/home/vboxfs/vendor/ocramius/package-versions/0d1e7190e461948bf156e9fea4add4ee' -d '/home/vboxfs/vendor/composer/e11a586c'
Plugin installation failed, rolling back
  - Removing ocramius/package-versions (1.5.1)

Installation failed, deleting ./composer.json.


  [RuntimeException]
  Could not delete /home/vboxfs/vendor/ocramius/package-versions/src/PackageVersions:


Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:217
 Composer\Util\Filesystem->unlink() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:170
 Composer\Util\Filesystem->removeDirectoryPhp() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:137
 Composer\Util\Filesystem->removeDirectory() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:238
 Composer\Downloader\FileDownloader->remove() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:299
 Composer\Downloader\DownloadManager->remove() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:224
 Composer\Installer\LibraryInstaller->removeCode() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:137
 Composer\Installer\LibraryInstaller->uninstall() at phar:///usr/local/bin/composer/src/Composer/Installer/PluginInstaller.php:66
 Composer\Installer\PluginInstaller->install() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:173
 Composer\Installer\InstallationManager->install() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:160
 Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:597
 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:229
 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/RequireCommand.php:218
 Composer\Command\RequireCommand->doUpdate() at phar:///usr/local/bin/composer/src/Composer/Command/RequireCommand.php:175
 Composer\Command\RequireCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:267
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:106
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:61
 require() at /usr/local/bin/composer:24

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

Tested with Cent OS 7, PHP 7.3, composer 1.9.0-1.6.0

I can install many other packages without problems under the vbofs:

composer require chadsikorra/php-simple-enum
composer require friendsofsymfony/rest-bundle
composer require ldaptools/ldaptools-bundle
composer require nelmio/api-doc-bundle
composer require paragonie/random_compat
composer require ramsey/uuid
composer require symfony/routing

However, only when using the sleep-trick at laravel/homestead#1240 (comment) in composer I can install ocramius/package-versions under vboxfs without problems. So it looks like there is something special in ocramius/package-versions which other packages do not have. But what?

@Ocramius
Copy link
Owner

Ocramius commented Aug 7, 2019

I'd need to have a reproducible test case for this to work: I no longer use vagrant/virtualbox either.

Since this started popping up a few weeks ago, with no changes to the filesystem operations in here, I suggest bisecting upstream first.

@alexgit2k
Copy link
Author

I am getting the same error also with the first version of package-versions
composer require ocramius/package-versions:1.0.0

I'll try to make a test case.

@Ocramius
Copy link
Owner

Ocramius commented Aug 7, 2019

Yeh, as I said, how files are written to disk barely changed here 😐

@alexgit2k
Copy link
Author

It can be reproduced with Windows 10, VirtualBox 6.0.10 + Extension Pack, Vagrant 2.2.5.

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network :private_network, ip: '192.168.56.100'

  config.vm.synced_folder ".", "/home/vboxfs"
end

Commands:

vagrant plugin install vagrant-cachier vagrant-hostmanager vagrant-vbguest
vagrant up
vagrant ssh

sudo rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install php73 git unzip
cd /home/vboxfs
curl -s https://getcomposer.org/installer | php73
php73 composer.phar require ocramius/package-versions -vvv

@Ocramius
Copy link
Owner

Anyone got a windows environment where to try this out? I don't have such an environment myself...

@alexgit2k
Copy link
Author

I can reproduce it on 2 different PCs. Anything you want me to do?

@Ocramius
Copy link
Owner

We probably need to test this in a windows environment on travis-ci (https://docs.travis-ci.com/user/reference/windows/)

@alexgit2k
Copy link
Author

VirtualBox/Vagrant is not running in travis-ci (see travis-ci/travis-ci#6060 (comment)).

@Jalle19
Copy link

Jalle19 commented Aug 13, 2019

Just stumbled upon this too after upgrading to PHP 7.3. Everything was fine as long as I used my existing vendor directory from an earlier installation where I used PHP 7.1, but as soon as I removed vendor and ran composer install this started happening again.

Vagrant + VirtualBox 6.0 + Ubuntu 18.04. There are no permission issues.

@Jalle19
Copy link

Jalle19 commented Aug 13, 2019

https://github.com/composer/composer/blob/master/src/Composer/Installer/PluginInstaller.php#L65 it all begins with this, but Composer unhelpfully swallows the exception message and trace.

@Jalle19
Copy link

Jalle19 commented Aug 13, 2019

I guess the real issue is that Composer gets all the way here: https://github.com/composer/composer/blob/dc964d6515f7e4d609b86ff5b2ba917e2550e783/src/Composer/Util/Filesystem.php#L137. It's supposed to be issuing an rm -rf foo but it fails for some inexplicable reason on contemporary VirtualBox installations. I love these problems...

@Ocramius
Copy link
Owner

@Jalle19 thanks for digging into this! It seems like it is indeed affecting all of composer, not just this package :-\

@Jalle19
Copy link

Jalle19 commented Aug 14, 2019

I tried a ton of things and it turns out that downgrading VirtualBox to 6.0.4 fixes this problem. According to the CHANGELOG they "Linux guests: shared folder performance and reliability improvements and missing features (bugs #17360, #819)", which did exactly the opposite.

@alexgit2k I suggest you try downgrading to 6.0.4 in case it fixes the issue for you too.

@Ocramius you can close this IMO since it's neither a bug in this package nor Composer, it just manifests itself with this one since Composer does some special read/write operations for plugins compared to "normal" dependencies.

@Ocramius
Copy link
Owner

I'll leave it open for now: lots of folks landing here, instead of opening new issues.

@LucidTaZ
Copy link

LucidTaZ commented Sep 11, 2019

I tried a ton of things and it turns out that downgrading VirtualBox to 6.0.4 fixes this problem. According to the CHANGELOG they "Linux guests: shared folder performance and reliability improvements and missing features (bugs #17360, #819)", which did exactly the opposite.

@alexgit2k I suggest you try downgrading to 6.0.4 in case it fixes the issue for you too.

@Ocramius you can close this IMO since it's neither a bug in this package nor Composer, it just manifests itself with this one since Composer does some special read/write operations for plugins compared to "normal" dependencies.

My coworker has this problem with VirtualBox 6.0.6, while I run VirtualBox 6.0.4 and have no issues. So I think you're onto something here.

Update: he reverted to 6.0.4 and ran the existing (Homestead) VM, which didn't work. Then he destroyed and recreated the VM and it worked again. So it's nothing conclusive unfortunately.

@alexgit2k
Copy link
Author

In the latest version 6.0.12 of VirtualBox they fixed a regression introduced by the shared folder change in 6.0.6 (see https://www.virtualbox.org/ticket/18737). However I still get the same error in 6.0.12.

I reverted back to VirtualBox 6.0.4 where it works without problems and created a ticket at VirtualBox: https://www.virtualbox.org/ticket/18937

@j-koehler
Copy link

j-koehler commented Sep 25, 2019

We had the very same problem but with a boot2docker setup. No matter if we used VB 6.0.4 or 6.0.10 or 6.0.12. We finally managed to solve the problem by upgrading to boot2docker 19.03.2 from 19.03.1.

Boot2Docker 19.03.1 uses VirtualBox Guest Additions v6.0.10
Boot2Docker 19.03.2 uses VirtualBox Guest Additions v5.2.32

So I guess there are definitely some issues with the newer guest extension when they downgrade the version.

Maybe it's a red herring, but you should try to switch to the older guest extension, it works fine with VirtualBox 6.x.

@Jalle19
Copy link

Jalle19 commented Sep 25, 2019

@mw-jko according to the change log you posted they didn't just downgrade the guest extensions, they downgraded the whole VirtualBox.

@j-koehler
Copy link

j-koehler commented Sep 25, 2019

@Jalle19

@mw-jko according to the change log you posted they didn't just downgrade the guest extensions, they downgraded the whole VirtualBox.

VirtualBox inside boot2docker-Iso does not make sense. Please check the changed lines:

RUN wget -O /vbox.iso "https://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso"; \

I'm successfuly running Docker Toolbox 19.03.1 with Virtualbox 6.0.12 using the Boot2Docker-Iso 19.03.2 (yay, need more layers :D) atm and I'm able to run composer install.

With the exakt same setup (but with Boot2Docker-Iso 19.03.1) I got the same error as the OP (@alexgit2k):

  [RuntimeException]
  Could not delete /home/vboxfs/vendor/ocramius/package-versions/src/PackageVersions:

@Jalle19
Copy link

Jalle19 commented Sep 25, 2019

Nevermind, you're right.

@FreekingDean
Copy link

I found using the 9p options cache=mmap has worked for me: gotoz/runq@20bec72

@frickenate
Copy link

frickenate commented Dec 3, 2019

I will downgrade to 6.0.4 later (if composer is having problems with this, chances are other software will too).

But... if someone just wants a "make it work right now" solution for this specific bug:

  1. You have to have unzip installed (eg. apt install unzip), so that composer will use that instead of php's unzip extension.

  2. Assuming which unzip shows /usr/bin/unzip.

  3. Assuming echo $PATH shows /usr/local/bin listed before /usr/bin.

  4. The hack (pasted in shell as root user):

cat >/usr/local/bin/unzip <<EOF
#!/bin/sh

/usr/bin/unzip "$@"
sleep 1
EOF

chmod 755 /usr/local/bin/unzip

Yeah, I did that. And it works. Hopefully a downgrade to VirtualBox 6.0.4 tomorrow is a better fix.

@Jalle19
Copy link

Jalle19 commented Dec 4, 2019

@frickenate WTF nice hack, it works :D

@ramsey
Copy link

ramsey commented Jan 22, 2020

I was able to reproduce this on macOS Catalina with VirtualBox 6.0.15 r135660 and Vagrant 2.2.6. Here are the steps to reproduce:

cat >Vagrantfile <<EOF
\$script = <<-SCRIPT
apt-get update
apt-get install -y php-cli php-json php-xdebug php-xml php-zip unzip composer
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/eoan64"
  config.vm.provision "shell", inline: \$script
  config.vm.synced_folder "./test", "/home/vagrant/test"
end
EOF

mkdir test
vagrant up
vagrant ssh

Then, inside the VM:

cd test/
composer require ocramius/package-versions

You should see this output:

Using version ^1.5 for ocramius/package-versions
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.5.1): Downloading (100%)
Plugin installation failed, rolling back
  - Removing ocramius/package-versions (1.5.1)

Installation failed, deleting ./composer.json.

In Filesystem.php line 217:

  Could not delete /home/vagrant/test/vendor/ocramius/package-versions/src/PackageVersions:


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>...]

It's important to note that this error only occurs when trying to install ocramius/package-versions in a directory that is shared with the host environment. If I try to composer require ocramius/package-versions in a directory that is local to the VM, it works.

@ramsey
Copy link

ramsey commented Jan 22, 2020

If I try the unzip hack described by @frickenate, I get a different error:

vagrant@ubuntu-eoan:~/test$ composer require ocramius/package-versions
Using version ^1.5 for ocramius/package-versions
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.5.1): Loading from cache
Plugin installation failed, rolling back
  - Removing ocramius/package-versions (1.5.1)

Installation failed, deleting ./composer.json.

In PluginManager.php line 209:

  Plugin ocramius/package-versions could not be initialized, class not found: PackageVersions\Installer

@ramsey
Copy link

ramsey commented Jan 22, 2020

I found a solution that works for me...

If you change the synced_folder type to rsync, then you're able to install this package, since the folder is still technically local to the VM. If you choose to go this route, be sure to read up on how rsync behaves with Vagrant, since the folders are not synchronized in real time. For my purposes, it's not necessary for them to stay synced. I just need the contents of the host copied into the VM for testing, so this does exactly what I need.

config.vm.synced_folder "./test", "/home/vagrant/test", type: "rsync"

@frickenate
Copy link

frickenate commented Jan 22, 2020

FYI, my unzip workaround was a temporary “make this work right now” hack. The correct solution to this problem, which I enacted the next day, is to downgrade to VirtualBox 6.0.4. This resolves the issue, as the behaviour/bug was introduced in VirtualBox 6.0.6 and hasn’t yet been fixed in any later 6.0 or 6.1 version.

@Dwarfex
Copy link

Dwarfex commented Mar 26, 2020

I ran into this problem aswell - my solution was removing the vendor folder and do: "composer install --no-scripts --no-custom-installers" which worked for me.

@agus-k
Copy link

agus-k commented Mar 30, 2020

I'm using bento/ubuntu-18.04 image. Downgrading Virtualbox alone didn't help, in my case. I found that downgrading the Virtualbox Guest Addition helps. I downgraded both Virtualbox and Guest Addition to version 6.0.0.

I found the following gist on how to downgrade the Guest Addition:
https://gist.github.com/claudiobizzotto/67dfcf66ebffca58b1075123c2e898f8

You'll need gcc, make and perl packages installed for the above gist.

@SmartGuyy
Copy link

Just checked @agus-k solution and it works fine for me.

@Ocramius
Copy link
Owner

This issue will disappear once #139 is implemented: at that point, this library should no longer write to disk during composer install steps

Ocramius added a commit that referenced this issue Aug 21, 2020
…NAME` constant

This simplifies the tool to no longer be a plugin: `PackageVersions\Versions` is now a much simpler
class that is no longer generated/written to disk at installation, and `ocramius/package-versions`
is no longer a `"type": "composer-plugin"`, but rather a more usual `"type": "library"` package.

This:

 * Fixes #138 - this library no longer changes `vendor` post-installation
 * Fixes #142 - the `rootPackage` version is now detected via composer, and no longer leads to
   changes in `vendor/ocramius/package-versions/src/PackageVersions/Versions.php` at each change
   of source root in a project
 * Fixes #152 - when `"lock": false` is used in composer, since we no longer access lock file
   information from sources of this package
 * Fixes #107 - writing to `vendor` is no longer happening from this library, so no file access
   rights should be needed.
Ocramius added a commit that referenced this issue Aug 21, 2020
…NAME` constant

This simplifies the tool to no longer be a plugin: `PackageVersions\Versions` is now a much simpler
class that is no longer generated/written to disk at installation, and `ocramius/package-versions`
is no longer a `"type": "composer-plugin"`, but rather a more usual `"type": "library"` package.

This:

 * Fixes #138 - this library no longer changes `vendor` post-installation
 * Fixes #142 - the `rootPackage` version is now detected via composer, and no longer leads to
   changes in `vendor/ocramius/package-versions/src/PackageVersions/Versions.php` at each change
   of source root in a project
 * Fixes #152 - when `"lock": false` is used in composer, since we no longer access lock file
   information from sources of this package
 * Fixes #107 - writing to `vendor` is no longer happening from this library, so no file access
   rights should be needed.
Ocramius added a commit that referenced this issue Aug 21, 2020
…the-need-for-generating-version-class

BC break: removed deprecated `PackageVersions\Versions::ROOT_PACKAGE_NAME` constant
@Ocramius Ocramius self-assigned this Aug 21, 2020
@Ocramius Ocramius added this to the 2.0.0 milestone Aug 21, 2020
@bilogic
Copy link

bilogic commented Dec 27, 2020

I suspect the root cause to be in VirtualBox's vboxsf, nothing to do with vagrant/composer/etc. Better to tackle it here https://www.virtualbox.org/ticket/8761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet