direnv icon indicating copy to clipboard operation
direnv copied to clipboard

Unexpected output when using `log_format` to disable normal logging

Open injust opened this issue 1 year ago • 1 comments

Describe the bug When log_format = '-' is used to disable normal logging in direnv.toml, the following output is shown:

-
%!!(MISSING)(EXTRA string=loading ~/path/to/.envrc)
-
%!!(string=+UV_ACTIVE ~PATH ~VIRTUAL_ENV)(EXTRA string=export %!s(MISSING))

This seems like a bug, especially because the literal - is being output.

In this case, my .envrc contains:

layout uv

To Reproduce direnv.toml:

[global]
log_format = '-'

Expected behavior Logging output should be disabled.

Environment

  • OS: macOS Sequoia
  • Shell: fish
  • Direnv version 2.36.0

injust avatar Apr 13 '25 04:04 injust

Running into the same thing- this other issue has some good workarounds for the new behavior: https://github.com/direnv/direnv/issues/1418

It looks like you need both the DIRENV_LOG_FORMAT= in the env variables and the new direnv.toml configuration set to silence the output

rossvz avatar Apr 25 '25 14:04 rossvz

Those instuctions seem incorrect and should probably be updated in the man page. Nothing in the code is acting upon the "-" sentinel value. The format string is processed as a Go fmt string without any further processing here.

In order to silence the status logs, one would theoretically need to set log_format = "", but that is currently being ignored.

antoineco avatar Jul 26 '25 16:07 antoineco