mnsami / composer-custom-directory-installer

A composer plugin, to install differenty types of composer packages in custom directories outside the default composer default installation path which is in the vendor folder.
https://packagist.org/packages/mnsami/composer-custom-directory-installer
MIT License
138 stars 27 forks source link

Does not remove package from custom directory #15

Closed carlos-reynosa closed 8 years ago

carlos-reynosa commented 9 years ago

Hi,

Can you confirm that composer should remove a package installed with this installer, if it was removed from the composer.json within the "require" section?

It seems that composer is not removing the custom package directory that was installed with this installer.

Thanks for your help!

Regards,

Carlos

carlos-reynosa commented 9 years ago

By the way i'm removing the package as a dependency an then running a composer update.

carlos-reynosa commented 9 years ago

Maybe the LibraryInstaller might need to override the uninstall function to take into account the custom paths?

uninstall(), here you can determine the actions that need to be executed when the package needs to be removed. - Composer Docs

carlos-reynosa commented 9 years ago

Seems like the getPackageBasePath function has the vendor directory hard coded in:

protected function removeCode(PackageInterface $package)
    {
        $downloadPath = $this->getPackageBasePath($package);
        $this->downloadManager->remove($package, $downloadPath);
    }

https://github.com/composer/composer/blob/9f6fdfd703f433bd0777fd89fb4684908a6c4f06/src/Composer/Installer/LibraryInstaller.php#L180-L184

protected function getPackageBasePath(PackageInterface $package)
    {
        $this->initializeVendorDir();
        return ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
    }

https://github.com/composer/composer/blob/9f6fdfd703f433bd0777fd89fb4684908a6c4f06/src/Composer/Installer/LibraryInstaller.php#L146-L151

mnsami commented 9 years ago

hello .. sorry for the late reply, but currently i'm heading off to my wedding vacations and i'll be available again after the 14th of October and I'll look into deep for all the comments you asked and pointed out.

thanks

mnsami commented 8 years ago

I think this issue is resolved automatically if you update your composer

Please check the latest commit at https://github.com/composer/composer/blob/master/src/Composer/Installer/LibraryInstaller.php#L162

    protected function getPackageBasePath(PackageInterface $package)
    {
        $installPath = $this->getInstallPath($package);
        $targetDir = $package->getTargetDir();
        if ($targetDir) {
            return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
        }
        return $installPath;
    }

if you are okay with it .. can you close the issue please?

thanks a lot.