devbox icon indicating copy to clipboard operation
devbox copied to clipboard

Hide banner message from python plugin

Open kadaan opened this issue 1 year ago • 6 comments

What problem are you trying to solve?

The python plugin logs a banner message no matter what.. https://github.com/jetpack-io/devbox/blob/7f1633f6834f8772d31b06588c637b8f12cbe7c7/plugins/pip/venvShellHook.sh#L8

If you use the shell init_hook to enter the virtual env it would be nice to suppress this message. This is especially important when scripts are execute via devbox run ..., because the message ends up just being cruft.

What solution would you like?

Create a environment variable set automatically by devbox: DEVBOX_ENTRYPOINT=run:<script_name> or DEVBOX_ENTRYPOINT=shell. Then the python plugin could not print the banner if DEVBOX_ENTRYPOINT=run:*. This would solve the run case.

Optionally, change the python plugin to not log the banner if a specific environment variable is present (ie. DEVBOX_PLYTHON_PLUGIN_HIDE_BANNER

Alternatives you've considered

Writing a wrapper around devbox would be another way to solve this, but that seems like more maintenance in the long run.

kadaan avatar Feb 21 '24 00:02 kadaan

I agree this is an annoying message. I'm not sure about adding a DEVBOX_ENTRYPOINT environment variable, but we could add a more general version of DEVBOX_PLYTHON_PLUGIN_HIDE_BANNER.

A few ideas:

  • Only show the message once. We could achieve this by saving a list in the .devbox directory of messages we've already shown.
  • Detect a DEVBOX_NO_HINTS environment variable (similar to brew's HOMEBREW_NO_ENV_HINTS) that suppresses plugin hints globally.
  • Now that devbox.json allows comments, we could add the message as a comment above packages that trigger plugins. This might be annoying if it messes up strict JSON syntax highlighting in editors though.

@Lagoja @mikeland73 any thoughts on this?

gcurtis avatar Feb 27 '24 21:02 gcurtis

Mind explaining the issue with allowing the plunging to know the entrypoint to them being called? Seems like a useful and generic way of solving the problem that could enable other scenarios.

kadaan avatar Feb 27 '24 22:02 kadaan

@gcurtis For this message in particular, maybe we move it into the plugin README and out of the script itself. The README would show when you install Python, but not on subsequent runs?

Lagoja avatar Feb 28 '24 17:02 Lagoja

I feel like you want to see the message if you are not already in the virtual env. I would prefer that there was a way to let the banner be logged after the unit hook ran. That way people could configure the unit hook to enter the virtual env and then the banner could be suppressed. In the case where you enter a shell, and the virtual environment is not active, the banner is useful. I still feel that being able to suppress logging during script runs could be very useful and generic.

kadaan avatar Feb 28 '24 18:02 kadaan

The youtuber DevOps Toolkit just released an Unleash Devbox video so decided to try it out and this is the 1st issue/annoyance that I am running into with devbox. Would be great to suppress this so I don't have to see this when I cd (direnv) into each of my project directories every time.

JtMotoX avatar Apr 01 '24 18:04 JtMotoX

I'd prefer the banner not be used, you can show notes on first install / add, that's enough.

glennpratt avatar Apr 12 '24 23:04 glennpratt

Banner has been moved out of shell, and will only show the first time that the Virtualenv is setup. This should be ~once per project.

Lagoja avatar May 31 '24 23:05 Lagoja