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

require-dev is not overriding require in composer.json #4978

Closed
FabioQ opened this issue Feb 29, 2016 · 3 comments
Closed

require-dev is not overriding require in composer.json #4978

FabioQ opened this issue Feb 29, 2016 · 3 comments
Labels

Comments

@FabioQ
Copy link

FabioQ commented Feb 29, 2016

Hi,
I was trying to use the require-dev on my local environment and on my UAT environment, but every time I use "composer update" I get errors if I have some packets in require-dev overriding require packages.
Here is an example of my composer.json:

... "require": {
        "php": ">=5.5.0",
        "wp/wordpress": "4.4.2",
        "wp/amazon-web-services": "0.2.2",
        "wp/members": "^1.0.2",
        "wp/nextgen-gallery-custom-fields": "^1.2.4",
        "wp/wpml-string-translation": "^2.2.6",
        "wp/sitepress-multilingual-cms": "^3.2.7",
        "wp/wpml-translation-management": "^2.0.5"
},
    "require-dev": {
        "wp/wp-functional-tests": "^1.0.0",
    "wp/sitepress-multilingual-cms": "dev-testing-3.3.6",
    "wp/wpml-string-translation": "dev-testing-2.3.6.1",
        "wp/wpml-translation-management": "dev-testing-2.1.5"
}, ...

when I run a composer update I get this error:

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Updating wp/wpml-string-translation (2.3.2 => dev-testing-2.3.6.1 ddc3c6b)
    Checking out ddc3c6b3923fe47deda4d8d....

  - Updating wp/sitepress-multilingual-cms (3.3.1 => dev-testing-3.3.6 164cab6)
    Checking out 164cab6c3c756ba031c58a3....



  [Composer\DependencyResolver\SolverProblemsException]
    Problem 1
      - The requested package wp/wpml-string-translation ^2.2.6 could not be found.
    Problem 2
      - The requested package wp/sitepress-multilingual-cms ^3.2.7 could not be found.
    Problem 3
      - The requested package wp/wpml-translation-management ^2.0.5 could not be found.
  Potential causes:
   - A typo in the package name
   - The package is not available in a stable-enough version according to your minimum-stability setting
     see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
  Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Am I missing something? Isn't the require-dev supposed to override require plugins? why it's just not finding my stable versions? (that of course find if I'm not using require-dev)

Thanks a lot

@Seldaek
Copy link
Member

Seldaek commented Feb 29, 2016

It's not overriding no, it's merging the two so ifthey don't match that creates problem. Requiring something in both require and require-dev isn't really a supported use case and very likely to result in problems. I would advise you to just pick if a package is needed only for development or not, and then have it listed only once.

@FabioQ
Copy link
Author

FabioQ commented Feb 29, 2016

So what should I do if I want to use continuous integration and build my package on different environment like prod, stage, dev, uat where stage and prod have require stable versions and on uat and dev I want to test different one? should I always do different packages standing alone?
It would be great to use require/require-dev to establish some sort of hierarchy (in the Continuous integration context)

@curry684
Copy link
Contributor

Your problem is in workflow, not technical - you should adopt a branch based workflow for maintaining different stages of development. Commonly you develop in master, test in version branches like 1.0.x, and release to tags. Git makes that workflow easy by merging issue branches to master, and commits in master back to version branches. CI tools like Travis are prepared for monitoring all branches and new tags for a given repository. As you can have different versions of composer.json in each commit and branch this solves your problem right away.

In the rare remaining cases where you would like to have several different instances of composer.json, for example to test a deployment with all suggested packages installed, you could just have another like composer-with-suggests.json and use the COMPOSER env variable:

COMPOSER=composer-with-suggest.json composer install

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

No branches or pull requests

3 participants