Skip to content

Commit

Permalink
fix: disable Xdebug for composer command, fixes #4219 (#5586)
Browse files Browse the repository at this point in the history
  • Loading branch information
stasadev committed Dec 4, 2023
1 parent 4ecddd9 commit 6f092e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/ddevapp/composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func (app *DdevApp) Composer(args []string) (string, string, error) {
Dir: app.GetComposerRoot(true, true),
RawCmd: append([]string{"composer"}, args...),
Tty: isatty.IsTerminal(os.Stdin.Fd()),
// Prevent Composer from debugging when Xdebug is enabled
Env: []string{"XDEBUG_MODE=off"},
})
if err != nil {
return stdout, stderr, fmt.Errorf("composer command failed: %v", err)
Expand Down
8 changes: 8 additions & 0 deletions pkg/ddevapp/ddevapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,8 @@ type ExecOpts struct {
Stderr *os.File
// Detach does docker-compose detach
Detach bool
// Env is the array of environment variables
Env []string
}

// Exec executes a given command in the container of given type without allocating a pty
Expand Down Expand Up @@ -1775,6 +1777,12 @@ func (app *DdevApp) Exec(opts *ExecOpts) (string, string, error) {
baseComposeExecCmd = append(baseComposeExecCmd, "--detach")
}

if len(opts.Env) > 0 {
for _, envVar := range opts.Env {
baseComposeExecCmd = append(baseComposeExecCmd, "-e", envVar)
}
}

baseComposeExecCmd = append(baseComposeExecCmd, opts.Service)

// Cases to handle
Expand Down

0 comments on commit 6f092e8

Please sign in to comment.