Article

Composer & Git Branch Names - A Doh! Moment

It was one of those moments of clarity followed quickly by a doh! from everyone.

We were trying to include a branch of one of our Symfony bundles in our project using composer but composer refused to see the branch.  We checked the repository and the branch was definitely there so we could not understand why composer was not able to check out the branch.

To include the branch were were trying:-

[digital@devserver devsite]$ php composer.phar require htg/pagination-bundle:v2

(any eagle-eyed people able to spot the issue yet?)

And the response we were getting was 

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

 Problem 1
   - The requested package htg/pagination-bundle v2 could not be found.
 Problem 2
   - Installation request for symfony/framework-standard-edition 2.4.x-dev -> satisfiable by symfony/framework-standard-edition[2.4.x-dev].
   - symfony/framework-standard-edition 2.4.x-dev requires htg/pagination-bundle v2 -> no matching package 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://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

To try and isolate the problem we used added the verbose (-v) flag to get more information and we then got

[digital@devserver devsite]$ php composer.phar require htg/pagination-bundle:v2 -v
./composer.json has been updated
Loading composer repositories with package information
Reading composer.json of htg/pagination-bundle (master)
Importing branch master (dev-master)
Reading composer.json of htg/pagination-bundle (v2)
Importing branch v2 (2.x-dev)
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

 Problem 1
   - The requested package htg/pagination-bundle v2 could not be found.
 Problem 2
   - Installation request for symfony/framework-standard-edition 2.4.x-dev -> satisfiable by symfony/framework-standard-edition[2.4.x-dev].
   - symfony/framework-standard-edition 2.4.x-dev requires htg/pagination-bundle v2 -> no matching package 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://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

We then realise that v2 was getting interpreted as 2.x-dev but that wasn't our branch name.  When we updated our require to be 

[digital@devserver devsite]$ php composer.phar require htg/pagination-bundle:2.x-dev

we got 

Reading composer.json of htg/pagination-bundle (master)
Importing branch master (dev-master)
Reading composer.json of htg/pagination-bundle (v2)
Importing branch v2 (2.x-dev)
Updating dependencies (including require-dev)
 - Updating htg/pagination-bundle (dev-master 8a58d14 => 2.x-dev fc90e71)
   Checking out fc90e719c3e227fb20330d9dd80c2d5814772a63

children-593313_1280.jpg

Conclusion

You can have a branch name of v[number] but composer will treat it as a version number and try and checkout [number].x-dev instead.  Our bundle was not ready to be a 2.0 but was more like a 0.2 as we were trying out an experimental code change and more consideration should have been given to the branch name.

Lesson learned though!

 
me.jpeg

I am a web developer specialising in web driven applications using PHP, MySQL, Symfony and Zend and I am currently working for the The Drum in Glasgow, Scotland.

Most days I can be found frantically coding away with EuroDance in my ears and consuming what I hope to be a never ending supply of coffee... happy days!

Want more like this?

Keep up-to-date with latest news from Inside the Agency using any of the following services

Recent articles

Behind the Paywall - An Insider Point of View

Over the years, a number of publishers have tried their hand at implementing a paywall. These efforts have been met with varying degrees of success:

paywall.jpg

The Sun introduced a paywall on the 1st August 2013, partially removed it in the summer of 2015 and removed it completely on the 30th November 2015. The Financial Times introduced its paywall in 2007, however, they chose to relax the paywall in 2015 in an effort to combat sluggish growth and The Times introduced its paywall in 2010, which recent news suggests it be performing well.

Read more

Four things that suck about project management

Project management is not a glamorous job.   The better you are, the less you’re noticed: things just hum along nicely, with no major conflicts or serious misunderstandings.  If you’re diligent, skilled, dedicated and competent, someone else will get credit.  The software, application, website or rebuild you so lovingly slaved over will be attributed to your boss, your client, or – if you’re lucky – to your developers or creatives.

In fact, the only time a project manager can rely on getting any real attention is when things go wrong.  A host of complex issues may be present – problematic management behaviour, shifting requirements, lack of necessary cooperation from the wider business, underinvestment in skill or resource – but the blame is ultimately yours.  You’re the project manager.

Read more

“My boss doesn’t get it.” The puzzle of motivation.

Management roles have traditionally focused on issuing assignments and offering rewards.  For much of the industrial age, this worked well.  In the vast majority of situations, people do work harder if they know they’ll get a financial bonus or more recognition.  Primed with 100 years of business advice, managers feel they have the tools they need to get things done, retain their staff and hit their targets.

carrot.jpg

But when they find themselves at the helm of a team of developers, or a mixed team of designers and developers, managers get confused.  The promise of rewards only goes so far.   Sometimes, incentives fail to generate any interest and may even lead to resistance.  Developers who never voice any dissatisfaction put in their notice and move on without any explanation, leaving you scratching your head.  It’s really confusing, and there are no easy answers. 

Read more

Advertisement

Digital Ocean

Chris's Reading List

www.thoughtworks.com

BFF @ SoundCloud

Our friends at SoundCloud embarked on a journey a few years ago that changed their system and moved it from a monolithic Rails application towards an ecosystem of microservices. Read more

The Drum

The Drum

Google'€™s AMP is bringing some much needed speed to mobile but the transition won'€™t be easy for publishers

A week after launching, the Google-led Accelerated Mobile Pages (AMP) initiative has raised more questions than answers for publishers... Read more

SitePoint

SitePoint

Quick Tip: How to Permanently Change SQL Mode in MySQL

MySQL 5.7 introduced some awkward changes for older codebases and tends to break apps. Here's how to temporarily (or permanently) lower the strictness level Read more

SitePoint

SitePoint

How to Build Your Own Dependency Injection Container

Andrew Carter builds a Dependency Injection container from scratch, showing you how that rocket science is really just fireworks strapped to lego figures! Read more

AuthorityLabs

AuthorityLabs

13 Reasons Your Organic Traffic is in Decline | It's Not a Penalty

The landscape of search engine optimization has changed drastically in the last 3-4 years. Even as it changes, a lot stays the same. It has been very challenging to see a multitude of friends and colleagues approach me with problems that often seem beyond repair with clients that they have worked with for years. Read more

TechCrunch

TechCrunch

WordPress Sites Now Support Google’s AMP To Make Mobile Pages Load Much Faster

Google has some big plans when it comes to making the web faster on your mobile phone. The company just added AMP-enabled pages in its mobile search results... Read more