Skip to content

Commit

Permalink
fix(cmd): changing home directory for root users (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f authored Dec 11, 2023
1 parent 75c1cc0 commit c2bd49c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,10 @@ func PrintJSONObject(obj interface{}) {
func PactusHomeDir() string {
home := ""
usr, err := user.Current()
if err == nil {
// Running as root, probably inside docker
if usr.HomeDir == "/root" {
home = "/pactus/"
} else {
home = filepath.Join(usr.HomeDir, "pactus")
}
if err != nil {
PrintWarnMsgf("unable to get current user: %v", err)
} else {
home = filepath.Join(usr.HomeDir, "pactus")
}
return home
}
Expand Down

0 comments on commit c2bd49c

Please sign in to comment.