scriptotek / php-marc

Simple interface for working with MARC records using the File_MARC package
MIT License
51 stars 11 forks source link

File_MARC version in composer.json not respected #18

Closed rudolfbyker closed 4 years ago

rudolfbyker commented 4 years ago

I'm not sure whether this is a bug with php-marc, or with some other dependency of it, or with composer, but here goes...

I have a composer.json file like this:

{
    "name": "rscdevelopers/rsc_oai_pmh_harvester",
    "type": "drupal-module",
    "description": "Harvest and decode biblios from an OAI-PMH source, like Koha and store them in Drupal.",
    "license": "MIT",
    "homepage": "https://www.drupal.org/project/rsc_oai_pmh_harvester",
    "minimum-stability": "stable",
    "require": {
        "scriptotek/marc": "~2.0",
        "caseyamcl/phpoaipmh": "^3.0",
        "guzzlehttp/guzzle": "^6.3",
        "ext-json": "*",
        "ext-simplexml": "*"
    }
}

composer update gives the following output:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
  - Installing caseyamcl/phpoaipmh (v3.0): Downloading (100%)         
  - Installing pear/pear_exception (v1.0.0): Loading from cache
  - Installing pear/file_marc (1.4.0): Loading from cache
  - Installing ck/php-marcspec (2.0.3): Loading from cache
  - Installing ck/file_marc_reference (v1.2.0): Loading from cache
  - Installing scriptotek/marc (v2.0.2): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.4.1): Loading from cache
pear/file_marc suggests installing pear/validate_ispn (Install optionally via your project's composer.json)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Writing lock file
Generating autoload files

So pear/file_marc 1.4.0 is installed, even though scriptotek/marc asks for ^1.1:

    "require": {
        "php": ">=5.6",
        "ck/file_marc_reference": "^1.2",
        "pear/file_marc": "^1.1"
    }

But maybe the problem lies in the composer.json file from ck/file_marc_reference:

    "require": {
        "ck/php-marcspec": "^2.0",
        "php": ">=5.6",
        "pear/file_marc": "@dev"
    }

I'm not sure whether this is something that should be solved in ck/file_marc_reference, in scriptotek/marc or in my own project.

rudolfbyker commented 4 years ago

Actually, I can fix this in my project by adding "pear/file_marc": "1.1.x", to require, but it feels like it should be fixed on a lower level. Maybe change ^1.1 to 1.1.x? I'm not sure how composer resolves the final version numbers, but it seems that 1.1.x takes precedence over @dev, but ^1.1 does not. Or maybe I'm missing something completely.

danmichaelo commented 4 years ago

I think that's expected behaviour for the caret operator

Ideally there should be no breaking changes before 2.0, so ^1.1 is interpreted as >= 1.1.0 < 2.0.0.

~1.1.0 could have been used to limit to <1.2.0

rudolfbyker commented 4 years ago

Whoops. I must have been reading the wrong docs.