Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix issue 2601 (dont fail on empty /nix folder) #2605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
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
Fix 2601
  • Loading branch information
ascknx committed Apr 29, 2025
commit 5d04475bb45c8d636a7aae59ef8c1390429ff7f5
8 changes: 8 additions & 0 deletions 8 internal/fileutil/fileutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func Exists(path string) bool {
return err == nil
}

func IsDirEmpty(path string) bool {
entries, err := os.ReadDir(path)
if err != nil {
return false
}
return len(entries) == 0
}

// FileContains checks if a given file at 'path' contains the 'substring'
func FileContains(path, substring string) (bool, error) {
data, err := os.ReadFile(path)
Expand Down
7 changes: 4 additions & 3 deletions 7 internal/nix/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func BinaryInstalled() bool {
return cmdutil.Exists("nix")
}

func dirExists() bool {
return fileutil.Exists("/nix")
func dirExistsAndIsNotEmpty() bool {
dir := "/nix"
return fileutil.Exists(dir) && !fileutil.IsDirEmpty(dir)
}

var ensured = false
Expand Down Expand Up @@ -57,7 +58,7 @@ func EnsureNixInstalled(ctx context.Context, writer io.Writer, withDaemonFunc fu
if BinaryInstalled() {
return nil
}
if dirExists() {
if dirExistsAndIsNotEmpty() {
if _, err = SourceProfile(); err != nil {
return err
} else if BinaryInstalled() {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.