Skip to content

Commit

Permalink
fix:[362] Try PATH if distrobox is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
nellfs authored and kbdharun committed Jun 17, 2024
1 parent 45ca8db commit 97bcbad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/apx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apxPath": "/usr/share/apx",
"distroboxpath": "/usr/share/apx/distrobox/distrobox",
"distroboxPath": "/usr/share/apx/distrobox/distrobox",
"storageDriver": "overlay"
}
}
17 changes: 16 additions & 1 deletion settings/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package settings
import (
"fmt"
"os"
"os/exec"
"path/filepath"

"github.com/spf13/viper"
Expand Down Expand Up @@ -64,9 +65,23 @@ func GetApxDefaultConfig() (*Config, error) {
// fmt.Printf("Using config file: %s\n\n", viper.ConfigFileUsed())
// }

distroboxPath := viper.GetString("distroboxPath")

_, err = os.Stat(distroboxPath)
if err != nil {
if os.IsNotExist(err) {
path, err := exec.LookPath("distrobox")
if err != nil {
fmt.Printf("Unable to find distrobox in PATH.\n")
} else {
distroboxPath = path
}
}
}

Cnf := NewApxConfig(
viper.GetString("apxPath"),
viper.GetString("distroboxPath"),
distroboxPath,
viper.GetString("storageDriver"),
)
return Cnf, nil
Expand Down

0 comments on commit 97bcbad

Please sign in to comment.