From 86a075e03066688648d3196d70dc9f9b742eade8 Mon Sep 17 00:00:00 2001 From: "Theodore R. Smith" Date: Fri, 24 Dec 2021 23:27:47 -0600 Subject: [PATCH] Added support for composer v2.2.0+. The problem is that composer v2.2.0+ changed the way that vendor bin scripts are executed. Now they are executed by an intermediary shell script in a way that causes their PWD to change to the project's bin-dir, breaking project root detection. See https://github.com/composer/composer/issues/10389 --- CHANGELOG.md | 3 +++ bin/composer | 9 ++++++++- bin/php | 9 ++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b5211e..f837e21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v7.1.2 +* **[2021-12-24 23:27:47 CDT]** Added support for composer v2.2.0+. + ## v7.1.1 * **[2021-12-24 15:36:38 CDT]** Fixed the ability of selecting the PHP version via the .env file. * **[2021-12-24 16:09:02 CDT]** Upgraded to PHP v7.4.27, 8.0.14, and 8.1.1. diff --git a/bin/composer b/bin/composer index ad66fda..01303ab 100755 --- a/bin/composer +++ b/bin/composer @@ -1,6 +1,13 @@ #!/usr/bin/env bash -ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" +# @see https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/ +# @see https://github.com/composer/composer/issues/10389 +SUB="/vendor/" +if [[ "$0" == *"$SUB"* ]]; then + ROOT="$(readlink -f /proc/$PPID/cwd)" +else + ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" +fi # Detect if it's running inside of docker and run it natively if it is. # @see https://stackoverflow.com/a/25518345/430062 diff --git a/bin/php b/bin/php index 6f3c4ca..146d44b 100755 --- a/bin/php +++ b/bin/php @@ -1,6 +1,13 @@ #!/bin/bash -ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" +# @see https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/ +# @see https://github.com/composer/composer/issues/10389 +SUB="/vendor/" +if [[ "$0" == *"$SUB"* ]]; then + ROOT="$(readlink -f /proc/$PPID/cwd)" +else + ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" +fi # Detect if it's running inside of docker and run it natively if it is. # @see https://stackoverflow.com/a/25518345/430062