Skip to content

Commit 4fd7ba0

Browse files
authored
[nix] Fix ensure nix installed (#467)
## Summary Fixes bug in ensure nix installed. @gcurtis was right. source does not work in sh. Changed with a `.`. My best guess is that I did not test the end-to-end installation when I switched this code from `bash` to `sh` in this [commit](dd72879#diff-5012a4a5b4cd2f8957a7f9aebcb2cca11654b6f85d72800aa8be9c482a644535R30) Also made a small fix to re-source after installation. This should prevent the user from having to re-run the command after nix is installed. (I thought this was working previously, but I'm not sure how) Edit: This can be improved by properly handling stderr. But I want to get this out fast so we can patch it. ## How was it tested? * Fresh ubuntu container, created user for single user install * `devbox init` and `devbox shell`
1 parent 3800d83 commit 4fd7ba0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/boxcli/setup.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ func ensureNixInstalled(cmd *cobra.Command, args []string) error {
7373
if err := nix.Install(cmd.ErrOrStderr()); err != nil {
7474
return err
7575
}
76+
77+
// Source again
78+
if err := nix.SourceNixEnv(); err != nil {
79+
return err
80+
}
81+
7682
cmd.PrintErrln("Nix installed successfully. Devbox is ready to use!.")
7783
return nil
7884
}

internal/nix/source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func SourceNixEnv() error {
2929
cmd := exec.Command(
3030
"/bin/sh",
3131
"-c",
32-
fmt.Sprintf("source %s ; echo '<<<ENVIRONMENT>>>' ; env", srcFile),
32+
fmt.Sprintf(". %s ; echo '<<<ENVIRONMENT>>>' ; env", srcFile),
3333
)
3434

3535
bs, err := cmd.CombinedOutput()

0 commit comments

Comments
 (0)