How do I get Composer to download the latest commit in the master branch from GitHub for a package?

44,118

Solution 1

There is only one way to grab the head of the repository:

"require": { "behat/mink-selenium2-driver" : "dev-master" }
"minimum-stability": "dev"

Oh well, at least two ways:

"require": { "behat/mink-selenium2-driver" : "dev-master as 1.1.x-dev" }
"minimum-stability": "dev"

Probably at least three ways:

"require": { "behat/mink-selenium2-driver" : "dev-master#2e73d8134ec8526b6e742f05c146fec2d5e1b8d6" }
"minimum-stability": "dev"

Because that repository actually aliased the master branch as 1.1.x-dev, this would also work without the minimum-stability affecting all other packages:

"require": { "behat/mink-selenium2-driver" : "1.1.*@dev" }

Solution 2

Simply specify the master branch:

composer require --dev behat/mink-selenium2-driver:dev-master

PS: the --dev is just to specify it's a test/development requirement, that's probably what you want.

Share:
44,118
Patrick
Author by

Patrick

I am a lead developer with two degrees in computer science. I have a background in computer (desktop and laptop) and projector repair as well as tech support for multiple companies. Most of my development is done in PHP and JavaScript. I have dabbled in Ruby, Java, Python, and others. In my position I find myself mostly working in Drupal 8 and Laravel. But I have worked with WordPress, OpenCart, Magento (ick!), OSCommerce, CodeIgniter, CakePHP, Laravel, and I have a dabbled in numerous other frameworks and CMSes. I am not shy at trying new libraries, tools, and systems. I have worked with MySQL and other RDBMS solutions. I have spent a little bit of time learning MongoDB and CouchDB. My skills are wide and varying. I am a hiring manager and have lead multiple teams of developers for several projects. My skills continue to grow and enhance. I am a nerd through and through and try to absorb and analyze every bit of knowledge I come across. My interests span through everything. Astronomy, Physics, Geology, Woodworking, Home Repair, Building and Creating things, and anything electronics.

Updated on July 09, 2022

Comments

  • Patrick
    Patrick almost 2 years

    I am trying to get Composer do download the latest commit for the Behat/MinkSelenium2Driver package. That particular repo only has a master branch. I have tried every method I can think of, including deleting the files and letting it pull them back in, to get it to work but it doesn't.

    How would I get it to pull in latest committed files or at least those from the commit I list below?

    Specifically I want to get this commit: https://github.com/Behat/MinkSelenium2Driver/commit/2e73d8134ec8526b6e742f05c146fec2d5e1b8d6

    Thanks, Patrick

  • Patrick
    Patrick over 10 years
    Option 4 doesn't work. I have tried it that way and several others (1.*@dev or 1.1.*@dev or 1.*@master). I have not tried using a "dev-master" option of any sort. My current minimum stability is "dev" and has been for a long time. I also tried a "@dev#2e73d8134ec8526b6e742f05c146fec2d5e1b8d6" but it didn't like parsing that. However I did not try it the way you mentioned above with dev-master (and not using the @ sign). I will try your options out and see what works.
  • Patrick
    Patrick over 10 years
    Ok, and the winner is Option #1. That pulled it correctly this time. Thank you kind sir!
  • Sven
    Sven over 10 years
    Well, it works for me now. It hasn't before, because my PHP-CLI lacked the curl extension, which was needed for one of the dependencies in the higher version that was needed to install your desired commit. After I satisfied this, it worked. Even with option 4.
  • Sven
    Sven over 10 years
    Note that you might need to delete either the vendor/ directory, or the ~/.composer/ cache directory to be sure any previously installed artefacts do not inhibit installation, i.e. switching from ZIP download to Git clones. You should also run install or update with -vv option to get more output on the decisisions made. It might be entirely possible that another package does not allow to run with the latest 1.1.x version, but with 1.0.x. This would prevent installation of that version.
  • Patrick
    Patrick over 10 years
    My PHP install has had the curl extension installed for awhile. So that wasn't the problem. Option 4 just got me the latest tagged version.
  • enchance
    enchance almost 9 years
    Be careful when using "minimum-stability": "dev". It's not recommended to do so so make sure there's always a good reason why.