Skip to content

Conversation

@savil
Copy link
Collaborator

@savil savil commented Jun 18, 2024

Summary

From the EnvOptions docblock:

// EnvOptions configure the Devbox Environment in the `computeEnv` function. // - These options are commonly set by flags in some Devbox commands // like `shellenv`, `shell` and `run`. // - The struct is designed for the "common case" to be zero-initialized as `EnvOptions{}`. 

This gets rid of the pseudo-global state in the Devbox struct where we were setting pure, preservePathStack and omitNixEnv values.

How was it tested?

TODO:

  • CICD should pass
  • Ensure devbox global and devbox omitNixEnv works as expected
  • Ensure pure works as expected for devbox shell --pure.
@savil savil force-pushed the savil/env-options branch from 3fbba9d to be9f114 Compare June 18, 2024 16:05
@savil savil force-pushed the savil/global-min-env branch from 8b2b47b to 5b66556 Compare June 18, 2024 16:15
@savil savil force-pushed the savil/global-min-env branch from 5b66556 to 0be27b4 Compare June 18, 2024 16:25
@savil savil force-pushed the savil/env-options branch from be9f114 to 3150ece Compare June 18, 2024 16:27
@savil savil requested review from gcurtis and mikeland73 June 18, 2024 16:29
@savil savil marked this pull request as ready for review June 18, 2024 16:29
@savil savil force-pushed the savil/env-options branch from 3150ece to 2fed34f Compare June 19, 2024 17:04
Copy link
Collaborator

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

// runDevboxServicesScript invokes RunScript with the envOptions set to the appropriate
// defaults for the `devbox services` scenario.
// TODO: move to services.go
func (d *Devbox) runDevboxServicesScript(ctx context.Context, cmdArgs []string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RunScriptWithDefaultOptions ?

Copy link
Collaborator Author

@savil savil Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm going to leave this as is, because "default options" may not be correct or obvious-in-meaning in all scenarios. I'll modify this in a follow up to be even more Services-specific.

Base automatically changed from savil/global-min-env to main June 19, 2024 21:57
savil added a commit that referenced this pull request Jun 19, 2024
…ands (#2150) …vars ## Summary In this PR, we change `devbox global` shell environment to omit the env-vars from `nix print-dev-env`. Instead, we rely on the `nix profile` that Devbox manages to introduce the global packages into `PATH`. As before, `nix profile` continues to be generated from the `buildInputs` from `nix print-dev-env <devbox-generated-flake>`. The motivation is: 1. `devbox global` adds a bunch of nix stdenv packages to the top of your `$PATH` variable, which can cause conflicts when trying to compile or build projects on your machine. 2. `devbox global` also sets a global `PYTHONPATH` variable that interferes with other packages, as well as python scripts that are installed/running on the host. This global `PYTHONPATH` is unnecessary because any python binaries installed by the user are already wrapped with the `PYTHONPATH` Implementation notes: - Sets `Devbox.envForPackageBins` boolean setting that controls whether the Devbox Environment is optimized for executing package binaries, or for developing software using the packages. - [x] see if this can be passed down as a function parameter (see #2159) - Adds `flagDefaultOptions` to `shellEnvCmd`. This is a nicer way of overriding the defaults in global, even for the `--recompute` flag that we had done before. - Refactors code into a `devbox.execPrintDevEnv` function to remove some of the complexity from the `devbox.computeEnv` function (thanks to finger-wagging by our linter tool ;) ). TODO: - [x] Verify `omitNixEnv` is still properly handling the useNixPrintDevEnvCache call paths ## How was it tested? CICD tests should pass TODO: - [x] Ensure the python global scenario works - [x] Ensure we can use common packages (fzf, ripgrep, etc.) in `devbox global` - [x] Thanks to @gcurtis vetted this PR helps resolve issues with a couple of repos: (rust: https://github.com/zed-industries/zed.git) and (golang with cgo: [github.com/Code-Hex/vz/example/macOS](http://github.com/Code-Hex/vz/example/macOS))
@savil savil force-pushed the savil/env-options branch from 2fed34f to 495274e Compare June 19, 2024 22:02
@savil savil merged commit 1573ae8 into main Jun 19, 2024
@savil savil deleted the savil/env-options branch June 19, 2024 22:20
@sentry
Copy link

sentry bot commented Jun 27, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ **Generic Error: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue
  • ‼️ **syscall.Errno: <redacted errors.withStack>: <redacted fs.PathError>: go.jetpack.io/devbox/internal/cuecfg in WriteFile View Issue
  • ‼️ **Generic Error: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue
  • ‼️ **Generic Error: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue
  • ‼️ *exec.ExitError: <redacted usererr.combined>: nix path-info exit code: 1, output: <redacted []uint8>, err: <redac... go.jetpack.io/devbox/internal/nix in StorePaths... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants