8
8
"context"
9
9
"fmt"
10
10
"io"
11
- "io/fs"
12
11
"maps"
13
12
"os"
14
13
"os/exec"
@@ -30,7 +29,6 @@ import (
30
29
"go.jetpack.io/devbox/internal/searcher"
31
30
"go.jetpack.io/devbox/internal/shellgen"
32
31
"go.jetpack.io/devbox/internal/telemetry"
33
- "go.jetpack.io/devbox/internal/wrapnix"
34
32
35
33
"go.jetpack.io/devbox/internal/boxcli/usererr"
36
34
"go.jetpack.io/devbox/internal/cmdutil"
@@ -215,18 +213,6 @@ func (d *Devbox) RunScript(ctx context.Context, cmdName string, cmdArgs []string
215
213
return err
216
214
}
217
215
218
- // By default we always remove bin wrappers when using `run`. This env var is
219
- // for testing. Once we completely remove bin wrappers we can remove this.
220
- // It helps simulate shell using "run".
221
- if includeBinWrappers , _ := strconv .ParseBool (
222
- os .Getenv ("DEVBOX_INCLUDE_BIN_WRAPPERS_IN_PATH" ),
223
- ); ! includeBinWrappers {
224
- env ["PATH" ] = envpath .RemoveFromPath (
225
- env ["PATH" ],
226
- wrapnix .WrapperBinPath (d .projectDir ),
227
- )
228
- }
229
-
230
216
// Used to determine whether we're inside a shell (e.g. to prevent shell inception)
231
217
// This is temporary because StartServices() needs it but should be replaced with
232
218
// better alternative since devbox run and devbox shell are not the same.
@@ -258,9 +244,8 @@ func (d *Devbox) RunScript(ctx context.Context, cmdName string, cmdArgs []string
258
244
return nix .RunScript (d .projectDir , strings .Join (cmdWithArgs , " " ), env )
259
245
}
260
246
261
- // Install ensures that all the packages in the config are installed and
262
- // creates all wrappers, but does not run init hooks. It is used to power
263
- // devbox install cli command.
247
+ // Install ensures that all the packages in the config are installed
248
+ // but does not run init hooks. It is used to power devbox install cli command.
264
249
func (d * Devbox ) Install (ctx context.Context ) error {
265
250
ctx , task := trace .NewTask (ctx , "devboxInstall" )
266
251
defer task .End ()
@@ -290,7 +275,7 @@ func (d *Devbox) NixEnv(ctx context.Context, opts devopt.NixEnvOpts) (string, er
290
275
upToDate , _ := d .lockfile .IsUpToDateAndInstalled ()
291
276
if ! upToDate {
292
277
cmd := `eval "$(devbox global shellenv --recompute)"`
293
- if strings . HasSuffix ( os . Getenv ( "SHELL" ), "fish" ) {
278
+ if isFishShell ( ) {
294
279
cmd = `devbox global shellenv --recompute | source`
295
280
}
296
281
ux .Finfo (
@@ -316,6 +301,8 @@ func (d *Devbox) NixEnv(ctx context.Context, opts devopt.NixEnvOpts) (string, er
316
301
envStr = fmt .Sprintf ("%s\n %s;\n " , envStr , hooksStr )
317
302
}
318
303
304
+ envStr += "\n " + d .refreshAlias ()
305
+
319
306
return envStr , nil
320
307
}
321
308
@@ -863,7 +850,6 @@ func (d *Devbox) computeNixEnv(ctx context.Context, usePrintDevEnvCache bool) (m
863
850
debug .Log ("nix environment PATH is: %s" , env )
864
851
865
852
// Add any vars defined in plugins.
866
- // TODO: Now that we have bin wrappers, this may can eventually be removed.
867
853
// We still need to be able to add env variables to non-service binaries
868
854
// (e.g. ruby). This would involve understanding what binaries are associated
869
855
// to a given plugin.
@@ -875,7 +861,6 @@ func (d *Devbox) computeNixEnv(ctx context.Context, usePrintDevEnvCache bool) (m
875
861
addEnvIfNotPreviouslySetByDevbox (env , pluginEnv )
876
862
877
863
env ["PATH" ] = envpath .JoinPathLists (
878
- filepath .Join (d .projectDir , plugin .WrapperBinPath ),
879
864
nix .ProfileBinPath (d .projectDir ),
880
865
env ["PATH" ],
881
866
)
@@ -888,7 +873,7 @@ func (d *Devbox) computeNixEnv(ctx context.Context, usePrintDevEnvCache bool) (m
888
873
// Add helpful env vars for a Devbox project
889
874
env ["DEVBOX_PROJECT_ROOT" ] = d .projectDir
890
875
env ["DEVBOX_CONFIG_DIR" ] = d .projectDir + "/devbox.d"
891
- env ["DEVBOX_PACKAGES_DIR" ] = d .projectDir + "/.devbox/virtenv/.wrappers"
876
+ env ["DEVBOX_PACKAGES_DIR" ] = d .projectDir + "/" + nix . ProfilePath
892
877
893
878
// Include env variables in devbox.json
894
879
configEnv , err := d .configEnvs (ctx , env )
@@ -1143,31 +1128,6 @@ func (d *Devbox) setCommonHelperEnvVars(env map[string]string) {
1143
1128
env ["LIBRARY_PATH" ] = envpath .JoinPathLists (profileLibDir , env ["LIBRARY_PATH" ])
1144
1129
}
1145
1130
1146
- // nixBins returns the paths to all the nix binaries that are installed by
1147
- // the flake. If there are conflicts, it returns the first one it finds of a
1148
- // give name. This matches how nix flakes behaves if there are conflicts in
1149
- // buildInputs
1150
- func (d * Devbox ) nixBins (env map [string ]string ) ([]string , error ) {
1151
- dirs := strings .Split (env ["buildInputs" ], " " )
1152
- bins := map [string ]string {}
1153
- for _ , dir := range dirs {
1154
- binPath := filepath .Join (dir , "bin" )
1155
- if _ , err := os .Stat (binPath ); errors .Is (err , fs .ErrNotExist ) {
1156
- continue
1157
- }
1158
- files , err := os .ReadDir (binPath )
1159
- if err != nil {
1160
- return nil , errors .WithStack (err )
1161
- }
1162
- for _ , file := range files {
1163
- if _ , alreadySet := bins [file .Name ()]; ! alreadySet {
1164
- bins [file .Name ()] = filepath .Join (binPath , file .Name ())
1165
- }
1166
- }
1167
- }
1168
- return lo .Values (bins ), nil
1169
- }
1170
-
1171
1131
func (d * Devbox ) projectDirHash () string {
1172
1132
hash , _ := cuecfg .Hash (d .projectDir )
1173
1133
return hash
@@ -1217,24 +1177,6 @@ func (d *Devbox) parseEnvAndExcludeSpecialCases(currentEnv []string) (map[string
1217
1177
return env , nil
1218
1178
}
1219
1179
1220
- // ExportifySystemPathWithoutWrappers is a small utility to filter WrapperBin paths from PATH
1221
- func ExportifySystemPathWithoutWrappers () string {
1222
- path := []string {}
1223
- for _ , p := range strings .Split (os .Getenv ("PATH" ), string (filepath .ListSeparator )) {
1224
- // Intentionally do not include projectDir with plugin.WrapperBinPath so that
1225
- // we filter out bin-wrappers for devbox-global and devbox-project.
1226
- if ! strings .Contains (p , plugin .WrapperBinPath ) {
1227
- path = append (path , p )
1228
- }
1229
- }
1230
-
1231
- envs := map [string ]string {
1232
- "PATH" : strings .Join (path , string (filepath .ListSeparator )),
1233
- }
1234
-
1235
- return exportify (envs )
1236
- }
1237
-
1238
1180
func (d * Devbox ) PluginManager () * plugin.Manager {
1239
1181
return d .pluginManager
1240
1182
}
0 commit comments