Problem/Motivation

The shellHook in template/flake.nix uses echo to print informational messages — "Entering development environment for ${projectName}" and "Use '?', '??', or 'flake-help' to see the commands provided in this flake." These messages are written to stdout.
When a downstream tool runs nix develop -c <command> and pipes the command's output to a structured-data parser (e.g., jq for JSON, or grep for table output), the shellHook banner text contaminates stdout. For example, running:

nix develop -c drush status --format=json 2>/dev/null

produces stdout like:

Entering development environment for myproject
Use '?', '??', or 'flake-help' to see the commands provided in this flake.
{"drupal-version": "11.1.0", ...}

— which is not valid JSON and breaks any consumer expecting clean output. The same issue affects the test shell (nix develop .#test).

Steps to reproduce

  1. Create a new project from the drupal-flake template: nix flake init -t git+https://git.drupalcode.org/project/drupal_flake
  2. Run a command that outputs structured data through the dev shell: nix develop -c drush status --format=json 2>/dev/null
  3. Observe that the JSON output is preceded by the shellHook banner messages, making it unparseable

Proposed resolution

Change echo to >&2 echo in the two shellHook definitions inside template/flake.nix:

  • Dev shell shellHook (~line 896): redirect both echo calls to stderr
  • Test shell shellHook (~line 1040): same change

This is a one-line prefix change per echo statement. Informational messages remain visible on the terminal (stderr is displayed by default) but no longer interfere with stdout-based pipelines. Example:

-              echo "Entering development environment for ${projectName}"
-              echo "Use '?', '??', or 'flake-help' to see the commands provided in this flake."
+              >&2 echo "Entering development environment for ${projectName}"
+              >&2 echo "Use '?', '??', or 'flake-help' to see the commands provided in this flake."

Remaining tasks

  • Review and merge the change
  • Tag a new release

User interface changes

None. The messages continue to display in the terminal; only their output stream changes from stdout to stderr.

API changes

None.

Data model changes

None.

Issue summary and fix AI-assisted by DeepSeek V4 Flash.

Comments

freelock created an issue. See original summary.

  • freelock committed 9f89bf80 on 1.0.x
    feat: #3592623 shellHook messages should go to stderr, not stdout
    
freelock’s picture

Status: Active » Fixed

This is already included/working.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.