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 google-closure-compiler #185

Closed
emaijala opened this issue Jan 24, 2016 · 9 comments
Closed

Unable to install google-closure-compiler #185

emaijala opened this issue Jan 24, 2016 · 9 comments
Assignees
Milestone

Comments

@emaijala
Copy link

Composer is unable to install google-closure-compiler package with the composer-asset-plugin due to a version number parsing issue. I found the actual issue to be in Composer's SemVer component, but it seems they're reluctant to change it (see composer/semver#32). So here goes in case there's something that could be done in composer-asset-plugin to remedy the issue.

Here's a minimal composer.json to reproduce the problem:

{
    "require": {
        "npm-asset/google-closure-compiler": "20150920.0.0"
    }
}

composer -vvv update output:

composer -vvv update
Reading ./composer.json
Loading config file /Users/ere/.composer/config.json
Loading config file /Users/ere/.composer/auth.json
Loading config file ./composer.json
Executing command (/Users/ere/src/composertest): git describe --exact-match --tags
Executing command (/Users/ere/src/composertest): git branch --no-color --no-abbrev -v
Executing command (/Users/ere/src/composertest): hg branch
Executing command (/Users/ere/src/composertest): svn info --xml
Reading ./composer.json
Loading config file /Users/ere/.composer/config.json
Loading config file /Users/ere/.composer/auth.json
Loading config file ./composer.json
Executing command (/Users/ere/src/composertest): git describe --exact-match --tags
Executing command (/Users/ere/src/composertest): git branch --no-color --no-abbrev -v
Executing command (/Users/ere/src/composertest): hg branch
Executing command (/Users/ere/src/composertest): svn info --xml



  [UnexpectedValueException]
  Could not parse version constraint 20150920.0.0: Invalid version string "20150920.0.0"



Exception trace:
 () at phar:///usr/local/bin/composer/vendor/composer/semver/src/VersionParser.php:467
 Composer\Semver\VersionParser->parseConstraint() at phar:///usr/local/bin/composer/vendor/composer/semver/src/VersionParser.php:248
 Composer\Semver\VersionParser->parseConstraints() at phar:///usr/local/bin/composer/src/Composer/Package/Loader/ArrayLoader.php:234
 Composer\Package\Loader\ArrayLoader->parseLinks() at phar:///usr/local/bin/composer/src/Composer/Package/Loader/ArrayLoader.php:124
 Composer\Package\Loader\ArrayLoader->load() at phar:///usr/local/bin/composer/src/Composer/Package/Loader/RootPackageLoader.php:86
 Composer\Package\Loader\RootPackageLoader->load() at phar:///usr/local/bin/composer/src/Composer/Factory.php:284
 Composer\Factory->createComposer() at phar:///usr/local/bin/composer/src/Composer/Factory.php:504
 Composer\Factory::create() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:245
 Composer\Console\Application->getComposer() at phar:///usr/local/bin/composer/src/Composer/Command/Command.php:53
 Composer\Command\Command->getComposer() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:88
 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:841
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:167
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:98
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
 require() at /usr/local/bin/composer:25


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--] [<packages>]...
@nazar-pc
Copy link

Should be fixed once composer/semver#48 is merged

@mbirth
Copy link

mbirth commented Feb 6, 2017

As you can read in composer/composer#6129 this is unlikely to happen. Could you probably implement some way of "translating" the version numbers?

Composer limits the number of digits to 6. So, e.g. making it the days since epoch (would be 17303 today) should be sufficient for a few decades.

For the record: I also opened google/closure-compiler-js#55 to ask them to change the versioning scheme.

@nazar-pc
Copy link

nazar-pc commented Feb 6, 2017

Translation would involve too many things, not sure this is a way anyone wants to go into.
I'm also not sure if this plugin might accept more versions by normalizing them on its own side (similarly to what I did in mentioned upstream PR).

The best thing I can imagine here is to allow at least exact versions matching, while ignoring everything else. Yes, we might miss some patch versions in this case, but at least we'll have package installed.

@mbirth
Copy link

mbirth commented Feb 6, 2017

Whatever it is, what's needed to fix this issue. But it seems it's up to you to implement something in the plugin since Composer is of the opinion that "640K ought to be enough for anybody".

@francoispluchino
Copy link
Member

@nazar-pc You should instead propose your PR directly in this plugin. It is in the Converter namespace that the conversion of the versions of the assets to Composer versions is done.

@nazar-pc
Copy link

nazar-pc commented Feb 6, 2017

I'm not familiar enough with this plugin to implement it quickly, but I'll try at some point, hopefully, soon.

@francoispluchino
Copy link
Member

The version converter tests are here.

@mbirth
Copy link

mbirth commented Feb 10, 2017

As a quickhack™, I added these lines to the Converter/SemverConverter.php:convertVersion() right before the return:

        if (preg_match('/^\d{7,}\./', $version)) {
            // composer can only handle 6 digits, convert somehow

            // cut off least significant digits
            $version = substr($version, -6);
        }

This is, at least, makes Composer usable for me again.

@francoispluchino francoispluchino added this to the 1.3.0 milestone Feb 12, 2017
@francoispluchino francoispluchino self-assigned this Feb 12, 2017
@francoispluchino
Copy link
Member

Added by 80760a9.

@emaijala The date format must be compatible with Composer: 20150920.000000 (YYYMMDD.hhmmss).

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

No branches or pull requests

4 participants