Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn

ef := o.EnvFile
if ef != "" && !filepath.IsAbs(ef) {
ef = filepath.Join(project.WorkingDir, o.EnvFile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the intent here. afaict filepath.Join(project.WorkingDir, o.EnvFile) should already make this path absolute, but maybe I missed something?
could you please clarify this in your PR description as the Docker Desktop issue is not public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the example where:

  • /some/path is where we execute the command
  • /some/path/wrkdir is the path passed as --project-directory
  • ./wrkdir/envs/my.env as the path passed in --env-file

in this we would end with /some/path/wrkdir + ./wrkdir/envs/my.env which would repeat wrkdir resulting in /some/path/wrkdir/wrkdir/envs/my.env which is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, because we resolve envfile based on project dir (which is definitely a bug) and we should resolve relative to command working dir. Then filepath.Abs is relevant. Earlier version of the diff I reviewed was doing some voodoo magic with WorkingDir so my confusion

ef, err = filepath.Abs(ef)
if err != nil {
return nil, err
}
}
for i, s := range project.Services {
s.CustomLabels = map[string]string{
Expand Down