Skip to content
Merged
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions internal/devconfig/configfile/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package configfile
import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/hashicorp/go-envparse"
Expand All @@ -25,10 +26,10 @@ func (c *ConfigFile) ParseEnvsFromDotEnv() (map[string]string, error) {
if !c.IsdotEnvEnabled() {
return nil, fmt.Errorf("env file does not have a .env extension")
}

file, err := os.Open(c.EnvFrom)
envFileAbsPath := path.Join(filepath.Dir(c.AbsRootPath), c.EnvFrom)
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks with absolute paths. I think we need to treat absolute and relative paths differently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pushed a commit to handle this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

What you want is:

envfileAbsPath := c.EnvFrom
if !filepath.IsAbs(c.EnvFrom) {
  envfileAbsPath = filepath.Join(c.AbsRootPath, c.EnvFrom)
}

file, err := os.Open(envFileAbsPath)
if err != nil {
return nil, fmt.Errorf("failed to open file: %s", c.EnvFrom)
return nil, fmt.Errorf("failed to open file: %s", envFileAbsPath)
}
defer file.Close()

Expand Down