From 44c62935739bac6416c88e8c130cc70ade002090 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 10 Oct 2024 13:58:08 -0600 Subject: [PATCH] fix: use Cmd instead of RawCmd to execute composer and put vendor/bin first in PATH, fixes #6602 (#6604) [skip ci] --- .../ddev-webserver/ddev-webserver-base-files/etc/bash.bashrc | 2 ++ .../ddev-webserver-base-files/etc/bash.nointeractive.bashrc | 1 + .../etc/bashrc/commandline-addons.bashrc | 2 +- pkg/ddevapp/composer.go | 4 +++- pkg/versionconstants/versionconstants.go | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.bashrc b/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.bashrc index 760e7d34fff..e8fd5a8c45f 100644 --- a/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.bashrc +++ b/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.bashrc @@ -6,6 +6,8 @@ # If not running interactively, don't do anything [ -z "$PS1" ] && return +export PATH="${DDEV_COMPOSER_ROOT:-/var/www/html}/vendor/bin:${PATH}" + # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize diff --git a/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.nointeractive.bashrc b/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.nointeractive.bashrc index 573d74462f6..3957f4e3aba 100644 --- a/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.nointeractive.bashrc +++ b/containers/ddev-webserver/ddev-webserver-base-files/etc/bash.nointeractive.bashrc @@ -1,4 +1,5 @@ # This file is loaded in non-interactive bash shells through $BASH_ENV +export PATH="${DDEV_COMPOSER_ROOT:-/var/www/html}/vendor/bin:${PATH}" for f in /etc/bashrc/*.bashrc; do source $f; done diff --git a/containers/ddev-webserver/ddev-webserver-base-files/etc/bashrc/commandline-addons.bashrc b/containers/ddev-webserver/ddev-webserver-base-files/etc/bashrc/commandline-addons.bashrc index fe18119a7f4..2f6ac96cbbc 100644 --- a/containers/ddev-webserver/ddev-webserver-base-files/etc/bashrc/commandline-addons.bashrc +++ b/containers/ddev-webserver/ddev-webserver-base-files/etc/bashrc/commandline-addons.bashrc @@ -1,4 +1,4 @@ -export PATH="~/bin:$PATH:/var/www/html/vendor/bin:/var/www/html/bin:$DDEV_COMPOSER_ROOT/vendor/bin" +export PATH="~/bin:$PATH:/var/www/html/bin" [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" diff --git a/pkg/ddevapp/composer.go b/pkg/ddevapp/composer.go index 4d3735c4650..02386784241 100644 --- a/pkg/ddevapp/composer.go +++ b/pkg/ddevapp/composer.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "runtime" + "strings" "github.com/ddev/ddev/pkg/fileutil" "github.com/mattn/go-isatty" @@ -17,10 +18,11 @@ func (app *DdevApp) Composer(args []string) (string, string, error) { return "", "", fmt.Errorf("failed to process pre-composer hooks: %v", err) } + argString := strings.Join(args, " ") stdout, stderr, err := app.Exec(&ExecOpts{ Service: "web", Dir: app.GetComposerRoot(true, true), - RawCmd: append([]string{"composer"}, args...), + Cmd: "composer " + argString, Tty: isatty.IsTerminal(os.Stdin.Fd()), // Prevent Composer from debugging when Xdebug is enabled Env: []string{"XDEBUG_MODE=off"}, diff --git a/pkg/versionconstants/versionconstants.go b/pkg/versionconstants/versionconstants.go index 78c4485b9fc..25c9f403973 100644 --- a/pkg/versionconstants/versionconstants.go +++ b/pkg/versionconstants/versionconstants.go @@ -11,7 +11,7 @@ var AmplitudeAPIKey = "" var WebImg = "ddev/ddev-webserver" // WebTag defines the default web image tag -var WebTag = "20241002_deviantintegral_vim_tiny" // Note that this can be overridden by make +var WebTag = "20241009_use_cmd_composer" // Note that this can be overridden by make // DBImg defines the default db image used for applications. var DBImg = "ddev/ddev-dbserver"