SimplyAdmire / ComposerPlugins

A collection of composer plugins for specific installation instruction for composer packages.
GNU Lesser General Public License v3.0
14 stars 8 forks source link

Make CodeSniffer installer OS independend in case of directory separator #2

Closed andygrunwald closed 10 years ago

andygrunwald commented 10 years ago

In the PHP_CodeSniffer project for TYPO3 we got an error that the TYPO3SniffPool is not installable on windows.

Here is the ticket: https://forge.typo3.org/issues/58190

It seems to be an error because of the hardcoded directory separator "/". This PR uses the PHP Constants DIRECTORY_SEPARATOR to be OS independent.

ATTENTION! This PR is not tested on Windows.

radmiraal commented 10 years ago

merged into master and tagged 1.0.1

andygrunwald commented 10 years ago

Thanks @radmiraal for this fast response :)

oliverklee commented 10 years ago

I've tested this on Windows using the following composer.json:

{ "require-dev": { "typo3-ci/typo3sniffpool": "dev-master" } }

This still fails:

$ ./composer.phar install --verbose Loading composer repositories with package information Installing dependencies (including require-dev)

Exception trace: () at C:\workspace\composer-test\vendor\simplyadmire\composer-plugins\SimplyAdmire\ComposerPlugins\Installers\PhpCodesnifferStandardInstaller.php:19 Composer\Util\ErrorHandler::handle() at C:\workspace\composer-test\vendor\simplyadmire\composer-plugins\SimplyAdmire\ComposerPlugins\Installers\PhpCo desnifferStandardInstaller.php:19 SimplyAdmire\ComposerPlugins\Installers\PhpCodesnifferStandardInstaller->getPackageBasePath() at phar://C:/workspace/composer-test/composer.phar/src/ Composer/Installer/LibraryInstaller.php:142 Composer\Installer\LibraryInstaller->getInstallPath() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/LibraryInstaller.php: 79 Composer\Installer\LibraryInstaller->install() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/InstallationManager.php:152 Composer\Installer\InstallationManager->install() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/InstallationManager.php:1 39 Composer\Installer\InstallationManager->execute() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer.php:543 Composer\Installer->doInstall() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer.php:216 Composer\Installer->run() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Command/InstallCommand.php:123 Composer\Command\InstallCommand->execute() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Console/Comman d/Command.php:252 Symfony\Component\Console\Command\Command->run() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Console/ Application.php:887 Symfony\Component\Console\Application->doRunCommand() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Con sole/Application.php:193 Symfony\Component\Console\Application->doRun() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Console/Application.php:127 Composer\Console\Application->doRun() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application .php:124 Symfony\Component\Console\Application->run() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Console/Application.php:83 Composer\Console\Application->run() at phar://C:/workspace/composer-test/composer.phar/bin/composer:43 require() at C:\workspace\composer-test\composer.phar:15

oliverklee commented 10 years ago

This works fine on Linux, though.

radmiraal commented 10 years ago

argh... line 17... That DIRECTORY_SEPARATOR should ofc. still be a / as it's the / in the composerpackage key... will push a fix

radmiraal commented 10 years ago

@oliverklee can you try again? Should be fixed in tag 1.0.2

oliverklee commented 10 years ago

Now this looks better ... I don't get the "Undefined offset" error anymore, but a different error:

$ ./composer.phar install --verbose Loading composer repositories with package information Installing dependencies (including require-dev)

Exception trace: () at phar://C:/workspace/composer-test/composer.phar/src/Composer/Util/Filesystem.php:167 Composer\Util\Filesystem->ensureDirectoryExists() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Downloader/DownloadManager.php:191 Composer\Downloader\DownloadManager->download() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/LibraryInstaller.php:155 Composer\Installer\LibraryInstaller->installCode() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/LibraryInstaller.php:86 Composer\Installer\LibraryInstaller->install() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/InstallationManager.php:152 Composer\Installer\InstallationManager->install() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer/InstallationManager.php:1 39 Composer\Installer\InstallationManager->execute() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer.php:543 Composer\Installer->doInstall() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Installer.php:216 Composer\Installer->run() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Command/InstallCommand.php:123 Composer\Command\InstallCommand->execute() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Console/Comman d/Command.php:252 Symfony\Component\Console\Command\Command->run() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Console/ Application.php:887 Symfony\Component\Console\Application->doRunCommand() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Con sole/Application.php:193 Symfony\Component\Console\Application->doRun() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Console/Application.php:127 Composer\Console\Application->doRun() at phar://C:/workspace/composer-test/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application .php:124 Symfony\Component\Console\Application->run() at phar://C:/workspace/composer-test/composer.phar/src/Composer/Console/Application.php:83 Composer\Console\Application->run() at phar://C:/workspace/composer-test/composer.phar/bin/composer:43 require() at C:\workspace\composer-test\composer.phar:15

It looks like in the path, two segments are missing: After "\C:\workspace\", the "composer-test" segment (the current directory) and the "vendor" segment are missing.

radmiraal commented 10 years ago

hey @oliverklee, sorry for not yet responding but I'm swamped with work atm... Will have a look asap

andygrunwald commented 10 years ago

Hey @radmiraal and @oliverklee, any update here?

radmiraal commented 10 years ago

hey @andygrunwald: nope, to dig deeper I would have to install PHP on my windows machine which takes time. As I'm pretty busy and would like to have a holiday I don't expect an update soon. But feel free to take care ;)

garbast commented 10 years ago

I can confirm that there is still a problem.

[RuntimeException] \C:\Users\mp\AppData\Roaming\squizlabs\php_codesniffer\CodeSniffer\Standards\TYPO3Sniffpool does not exists and could not be created.

This is, because the path should be: \C:\Users\mp\AppData\Roaming\Composer\vendor\squizlabs\php_codesniffer\CodeSniffer\Standards\TYPO3Sniffpool

I dont know composer enough to fix it myself.

pscheit commented 9 years ago

I can confirm this, too.

Would this fix the problem? https://github.com/pscheit/ComposerPlugins/commit/24e4d92e9548cbb09270fb779c987ba1e3ae4252

If I understand the code correctly the installer fakes the installation target path for composer to be another package (the php codesniffer package) so the files will be installed into the vendor directory?

If this is the case the code before was just very complicated to find out the vendor path and change into the correct directory?

can someone review that and test that on unix?