Macports and No Composer?

25 April, 2024

I was listening to Webchick's presentation on Upgrading YOUR Module to Drupal 8 (https://www.youtube.com/watch?v=wKdU2Q1NIZQ), following along with my own contributed module (https://drupal.org/project/node_theme) and when she reached a seemingly innocuous step

  • Installation:
    • drush dl drupalmoduleupgrader
    • cd drupalmoduleupgrader
    • composer install

I received the following response in my Mac terminal window

 

-bash: composer: command not found

Well, hell. I checked a few things, and yup, no composer to be found. I figure I'm not the only one running into this (although I'm late to the D8 upgrade game, so maybe so!).

 

If you are on a Mac, you're probably using Vbox, MAMP, or Macports. I'm going to describe installing composer in an environment using Macports. First, be aware that 

sudo port install composer

yields nothing. It's quite possible that there's some jinky package name that would have resulted in composer being installed, but I was feeling particularly ornery and impatient tonight, so I moved on without checking.

curl -sS https://getcomposer.org/installer | php

had better results, for a moment, and then this

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl

Fair enough. I'm running php 5.5 (yup, 5.6 upgrade next), and this was easily taken care of with the following

sudo port install php55-openssl
--->  Computing dependencies for php55-openssl
--->  Fetching archive for php55-openssl
--->  Attempting to fetch php55-openssl-5.5.33_0.darwin_15.x86_64.tbz2 from http://packages.macports.org/php55-openssl
--->  Attempting to fetch php55-openssl-5.5.33_0.darwin_15.x86_64.tbz2 from http://lil.fr.packages.macports.org/php55-openssl
--->  Attempting to fetch php55-openssl-5.5.33_0.darwin_15.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/php55-openssl
--->  Fetching distfiles for php55-openssl
--->  Verifying checksums for php55-openssl
--->  Extracting php55-openssl
--->  Configuring php55-openssl
--->  Building php55-openssl
--->  Staging php55-openssl into destroot
--->  Installing php55-openssl @5.5.33_0
--->  Activating php55-openssl @5.5.33_0
--->  Cleaning php55-openssl
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.

Let's try it again

 

curl -sS https://getcomposer.org/installer | php

All settings correct for using Composer
Downloading...
Composer successfully installed to: /Users/jag/temp/composer.phar
Use it: php composer.phar

Much better! Ok, now

 

sudo mv composer.phar /usr/local/bin/composer

And a test just to make sure

composer --version
Composer version 1.0-dev (a8e9df55dc62d8806360be2f79ad112b8678d397) 2016-03-17 11:42:19

 

Login or Register to Comment!