You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[config] look for the devbox.json file in parent directories as well (#200)
## Summary
**Motivation**
Previously, a user would need to specify the directory of the
devbox.json when
invoking `devbox shell` or `devbox build` and similar commands. In the
absence,
of an explicit directory argument, we would assume the user is saying
that
the devbox.json file is in the current directory.
This PR changes this to look for the devbox.json file in the
specified-directory, or current directory if none specified,
AND any parent directory.
This is desirable for a few reasons:
1. Convenience: it is nice especially for mono-repos to be located in a
sub-directory
and be able to invoke `devbox shell` or `devbox build`, in a manner
similar to
how `git` works.
2. Enable `devbox add` and `devbox rm` to run from any sub-directory.
These commands
currently _require_ the user to be located in the "directory of the
devbox.json".
With this PR, this requirement is relaxed so that the commands can be
run more naturally
in any sub-directory as well.
Fixes#185
## How was it tested?
- `devbox shell` and `devbox build` inside a sub-directory
```
# this directory has a devbox.json
> cd testdata/rust/rust-stable
> mkdir fake-dir
> cd fake-dir
# verify shell is using the rustc from the nix store
> devbox shell
(devbox) > which rustc
> devbox build
> docker run devbox
> devbox add openssl
> git diff ../devbox.json
diff --git a/testdata/rust/rust-stable/devbox.json b/testdata/rust/rust-stable/devbox.json
index 288dade..66982f9 100644
--- a/testdata/rust/rust-stable/devbox.json
+++ b/testdata/rust/rust-stable/devbox.json
@@ -1,3 +1,9 @@
{
- "packages": ["rust-bin.stable.latest.default"]
-}
+ "packages": [
+ "rust-bin.stable.latest.default",
+ "openssl"
+ ],
+ "shell": {
+ "init_hook": null
+ }
+}
\ No newline at end of file
> devbox rm openssl
> git diff
# none! as expected (not quite, I'm lying, there's been some unrelated changes which still show up)
```
- `devbox shell` and `devbox build` in a directory containing a
devbox.json
- did these commands in `testdata/rust/rust-stable`
- explicitly specify the folder of the devbox.json
```
> cd testdata/rust
> devbox shell rust-stable
```
- Error scenario
```
> cd testdata/rust/
> devbox shell
Error: No devbox.json found in this directory, or any parent directories. Did you run `devbox init` yet?
> devbox build
Error: No devbox.json found in this directory, or any parent directories. Did you run `devbox init` yet?
```
0 commit comments