jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.98k stars 190 forks source link

`devbox global shellenv` should be silent (and always fast) #1338

Open gcurtis opened 11 months ago

gcurtis commented 11 months ago

Current Behavior (bug)

After adding eval "$(devbox global shellenv)" to my ~/.zprofile, I sporadically see an "Ensuring packages are installed" message when opening a new terminal window/tab. I'm not entirely sure what causes it, as I haven't run any other devbox global commands in days.

Seeing this message and having devbox block me from typing in new tab (even if for a few seconds) becomes really annoying. We should ensure that devbox global shellenv consistently finishes quickly.

Expected Behavior (fix)

No output from eval "$(devbox global shellenv)" and faster shell startup times.

Additional context

$ devbox version
0.5.10
{
  "packages": [
    "nodejs@20",
    "yq@latest",
    "awscli2@latest",
    "bash@latest",
    "brotli@latest",
    "cmark@latest",
    "dash@latest",
    "delve@latest",
    "direnv@latest",
    "fish@latest",
    "flyctl@latest",
    "gh@latest",
    "git@latest",
    "gnupg@latest",
    "go_1_20@latest",
    "golangci-lint@latest",
    "graphviz@latest",
    "jq@latest",
    "nginx@latest",
    "nixpkgs-fmt@latest",
    "openssh@latest",
    "postgresql@latest",
    "python3@latest",
    "readline@latest",
    "ripgrep@latest",
    "sentry-cli@latest",
    "shellcheck@latest",
    "sqlfluff@latest",
    "sqlite@latest",
    "terraform@latest",
    "tree@latest",
    "vim@latest",
    "xz@latest",
    "zsh@latest",
    "zstd@latest",
    "k6@latest",
    "kubernetes-helm@latest"
  ],
  "shell": {}
}
savil commented 11 months ago

One situation this can occur in is:

Had you just updated devbox?

gcurtis commented 11 months ago

I didn't update devbox, but I do switch between the dev build and the release build. I don't think I've run any global commands with either of them though. The eval in my ~/.profile is hardcoded to always use /usr/local/bin/devbox.

gcurtis commented 11 months ago

I did verify that running non-global Devbox commands can trigger this. I ran:

$ cd `mktemp -d`
$ devbox init
$ devbox add flake:nixpkgs/nixpkgs-unstable#legacyPackages.aarch64-darwin.go

Then opened a new tab and saw the "Ensuring packages are installed" message. Note that in this case I was using the dev version of devbox, not the release in /usr/local/bin. It still seems odd that it would affect the global package caching though.

claytonrcarter commented 10 months ago

faster shell startup times

I started using devbox as a homebrew replacement (ie only global commands aside from search) the other day and immediately noticed lags in new shell tabs, which I believe are primarily related to async updates to my prompt (I'm using fish w/ tide). Running devbox global shellenv --init-hook from an existing shell isn't super slow, but it's not really fast either: I clocked it at +/-125ms. I hate complaining about 125ms, but it adds up and is definitely notable, esp when one is used to shells starting instantly.

Lagoja commented 10 months ago

Related to #1350