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
[bin wrappers] add --omit-wrappers-from-path to shellenv to prevent a binary from invoking a wrapped-binary. (#1151)
## Summary
**Motivation**
In elixir projects, `iex -S mix <script>` has the `iex` interpreter
invoking the
`mix` build tool. However, the `mix` build tool has been wrapped by
devbox in a bash script.
And this leads to a failure as `iex` is unable to interpret a bash
script.
**Fix**
Binaries should be able to directly invoke other installed binaries.
We implemented the binary-wrappers so that the shell-environment is
correctly
configured prior to the installed binary being invoked. In this case,
the `iex`
binary wrapper will run thereby correctly configuring the environment.
Any subsequent
binary invoked in the same sub-shell will inherit this up-to-date
environment. So,
the other binaries can be directly invoked (instead of the
binary-wrapper scripts).
**Implementation**
In this PR, we change the `PATH` that is set within a binary-wrapper.
Specifically, the `PATH` has the form:
```
<project-dir>/.devbox/virtenv/.wrappers/bin : <project-dir>/.devbox/nix/profile/default/bin
```
Within the binary-wrapper, we now omit the `.wrappers/bin` directory
from PATH
by using a new hidden flag `--omit-wrappers-from-path` on `devbox
shellenv`.
**perf analysis**
I expect the perf impact to be minimal.
1. Speed up: Binaries invoking other binaries will be a bit faster since
they no longer first execute the binary-wrapper.
2. Slowdown: we remove one layer of caching. Previously, we'd check the
shellenv-hash in the binary wrapper, and skip invoking `devbox shellenv`
if the hash was up-to-date. Now, on every invocation of a binary-wrapper
we'll call `devbox shellenv`. This should still be fast due to the
internal caching we do within `devbox shellenv`.
Fixes#1142
## How was it tested?
BEFORE: doing `devbox run -- iex -S mix` would result in the error in
the linked issue.
AFTER:
```
> devbox run -- iex -S mix
* creating .nix-mix/archives/hex-2.0.6
* creating .nix-mix/elixir/1-14/rebar3
Resolving Hex dependencies...
Resolution completed in 0.015s
Unchanged:
cowboy 2.9.0
cowlib 2.11.0
ranch 1.8.0
All dependencies are up to date
Erlang/OTP 25 [erts-13.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Hello World!
Interactive Elixir (1.14.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Goodbye World
15:14:23.204 [notice] Application elixir_hello exited: shutdown
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
```
Also - did test plan of #1093
to verify `devbox update` continues working. A sanity check since we
dropped ShellEnvHash from the wrappers and I wanted to ensure this works
as expected.
&flags.pure, "pure", false, "If this flag is specified, devbox creates an isolated environment inheriting almost no variables from the current environment. A few variables, in particular HOME, USER and DISPLAY, are retained.")
47
48
49
+
// This flag is to be used by our generated bin-wrappers shell script.
50
+
command.Flags().BoolVar(
51
+
&flags.omitWrappersFromPath, "omit-wrappers-from-path", false, "If this flag is specified, "+
52
+
"the PATH from shellenv will not include the binary wrappers")
0 commit comments