0

MacOS 10.13.3 (17D102)
I have composer 1.6.3 installed on PHP 7.1.7.

My end goal is to set up Drupal 8 in a dual Docker container setup; web in one, DB in another. We have scripts to do that. I cannot update this script.

When I try to run that script, I get errors like "composer: command not found".

On the command line, composer works, but in my .bash_profile, I see:

alias composer="php /usr/local/bin/composer.phar"

so that alias isn't available to my script (guess).

Others running composer on Mac don't have the alias. On their machines:

type composer

reveals

composer is hashed (/usr/local/bin/composer)

So they don't use an alias and the script does work.

What is the best way to get composer available to scripts? A fresh and different install method for composer?

Robert Achmann
  • 1,986
  • 3
  • 40
  • 66
  • 3
    Don't use aliases. They are only useful for interactive shells and even then functions are superior. This is a FAQ. – tripleee Mar 06 '18 at 15:41
  • It was not I that used the alias - that's how the upgrade to 10.13 made it. Now I just want to use a script that calls composer – Robert Achmann Mar 06 '18 at 15:43
  • So you don't have `/usr/local/bnn/composer` and your question is actually what did the others do to install that? Maybe ask them. – tripleee Mar 06 '18 at 15:46
  • I know. I have /usr/local/bin/composer.phar - why would 10.13 use an alias at all, if it's not the best way? – Robert Achmann Mar 06 '18 at 15:48
  • The OS installer didn't create that alias. – chepner Mar 06 '18 at 15:56
  • Wildly speculative, if the file doesn't exist, you can create it with `printf '%s\n' '#!/bin/sh' 'exec php /usr/local/bin/composer.phar' >/tmp/composer; sudo install -m 644 /tmp/composer /usr/local/bin` if you have `sudo`. If it doesn't work, `sudo rm /urs/local/bin/composer`. This is guesswork, obviously. Installing the same version as your colleagues is probably a better solution. – tripleee Mar 06 '18 at 16:38
  • I've removed the alias and, after making a backup, mv'd the/usr/local/bin/composer.phar to /usr/local/bin/composer and made it executable. Because it has '#!/usr/bin/env php' at the top, php runs it when you call it anyway. I'm sorry, I have never had reason to add such an alias and @chepner I believe you because it simply doesn't make sense once you stop to think. Something must have added the alias, but I don't know. – Robert Achmann Mar 06 '18 at 18:41

0 Answers0