nx icon indicating copy to clipboard operation
nx copied to clipboard

Nx not using terminal UI

Open benwainwright opened this issue 6 months ago • 4 comments

Current Behavior

Running nx commands looks exactly like it did with previous versions

Expected Behavior

Expecting to see the new terminal UI when I run nx commands in the terminal

GitHub Repo

https://github.com/nrwl/nx-examples

Steps to Reproduce

  1. Clone repo
  2. Install dependencies
  3. Run npm run test

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.2.0
OS             : darwin-x64
Native Target  : x86_64-macos
yarn           : 4.2.2

nx                     : 21.0.0-rc.4
@nx/js                 : 21.0.0-rc.4
@nx/jest               : 21.0.0-rc.4
@nx/eslint             : 21.0.0-rc.4
@nx/workspace          : 21.0.0-rc.4
@nx/angular            : 21.0.0-rc.4
@nx/cypress            : 21.0.0-rc.4
@nx/devkit             : 21.0.0-rc.4
@nx/eslint-plugin      : 21.0.0-rc.4
@nx/module-federation  : 21.0.0-rc.4
@nx/react              : 21.0.0-rc.4
@nx/rspack             : 21.0.0-rc.4
@nx/web                : 21.0.0-rc.4
@nx/webpack            : 21.0.0-rc.4
typescript             : 5.7.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/cypress/plugin
@nx/jest/plugin
---------------------------------------
Community plugins:
@ngrx/component-store : 19.0.0
@ngrx/effects         : 19.0.0
@ngrx/entity          : 19.0.0
@ngrx/operators       : 19.0.0
@ngrx/router-store    : 19.0.0
@ngrx/store           : 19.0.0
@ngrx/store-devtools  : 19.0.0
---------------------------------------
Cache Usage: 4.21 KB / 93.15 GB

Failure Logs


Package Manager Version

yarn 4.2.2

Operating System

  • [x] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

I get the same behaviour in my own monorepo which is NX v21.3

benwainwright avatar Jun 11 '25 07:06 benwainwright

@claude Can you look at the logic for when the TUI is enabled and propose some things for the user to check please?

FrozenPandaz avatar Jun 13 '25 14:06 FrozenPandaz

Claude finished @FrozenPandaz's task —— View job


I've analyzed the TUI enablement logic in the Nx codebase and compiled troubleshooting steps for @benwainwright.

How Nx Determines TUI Enablement

The TUI enablement logic is in /packages/nx/src/tasks-runner/is-tui-enabled.ts and follows this priority order:

  1. Terminal Capability Check: Must support TTY and Unicode
  2. CLI Arguments: --output-style flag (highest priority)
  3. Environment Variable: NX_TUI=true/false
  4. Environment Detection: CI/Windows/WASM checks
  5. nx.json Configuration: tui.enabled property
  6. Default: Enabled if system is capable

Troubleshooting Steps

Here are the most likely causes and things to check:

1. Check Environment Variables

# Check if NX_TUI is set to false
echo $NX_TUI

# Check if you're in a CI-like environment
echo $CI
echo $GITHUB_ACTIONS
echo $BUILDKITE
# ... (various CI environment variables)

2. Check Terminal Capability

# Verify TTY support
node -e "console.log('TTY:', process.stderr.isTTY)"

# Check your TERM environment variable
echo $TERM
echo $TERM_PROGRAM

3. Verify CLI Arguments

  • Check if you're using --output-style with values like static, stream, or dynamic-legacy
  • Try explicitly enabling TUI: npm run test -- --output-style=tui

4. Check nx.json Configuration

Look for a tui section in your nx.json:

{
  "tui": {
    "enabled": false  // This would disable TUI
  }
}

5. Test Direct Nx Commands

Instead of npm run test, try running Nx directly:

# Force TUI mode
NX_TUI=true npx nx run-many --target=test --output-style=tui

# Or with explicit output style
npx nx run-many --target=test --output-style=tui

6. Debug TUI Enablement

Add this temporary debug script to see what's happening:

node -e "
const { shouldUseTui } = require('./node_modules/nx/src/tasks-runner/is-tui-enabled');
const { readNxJson } = require('./node_modules/nx/src/config/nx-json');
console.log('TUI enabled:', shouldUseTui(readNxJson(), { outputStyle: undefined }));
"

Most Likely Causes

Given your setup (macOS, Node 22.2.0, Nx 21.0.0-rc.4):

  1. Hidden CI Environment: Some environment variable might be making Nx think you're in CI
  2. npm script wrapper: The npm run test command might be setting --output-style to something other than tui
  3. nx.json configuration: The repo might have tui.enabled: false
  4. Terminal emulator: Your terminal might not be reporting TTY capability correctly

Quick Fix Attempts

Try these in order:

# 1. Force TUI via environment variable
NX_TUI=true npm run test

# 2. Use direct nx command with explicit TUI
npx nx run-many --target=test --output-style=tui

# 3. Skip capability check (for debugging)
NX_TUI_SKIP_CAPABILITY_CHECK=true NX_TUI=true npm run test

Let me know what you find with these checks, and I can help narrow down the specific issue!

claude[bot] avatar Jun 13 '25 14:06 claude[bot]

  1. None of these environment variables are set

❯ node -e "console.log('TTY:', process.stderr.isTTY)"

TTY: true
~/repos/nx-examples master
❯ echo $TERM
echo $TERM_PROGRAM

xterm-256color
WezTerm
  1. No flags of any kind are being used, but... when I add it explicitly with npm run test -- --output-style=tui it does work
  2. There is nothing related to the tui in my nx.json
  3. For both options in this section, the tui does work
~/repos/nx-examples master
❯ node -e "
const { shouldUseTui } = require('./node_modules/nx/src/tasks-runner/is-tui-enabled');
const { readNxJson } = require('./node_modules/nx/src/config/nx-json');
console.log('TUI enabled:', shouldUseTui(readNxJson(), { outputStyle: undefined }));
"

TUI enabled: false

For all the options in the 'quick fix attempts' section, the tui DOES work, which is great... however, I don't consider this a fix - there is nothing in the documentation that suggests I should have to enable this feature explicitly, and I'd prefer not to have to do it for every command.

benwainwright avatar Jun 13 '25 18:06 benwainwright

is this related to #31588 and #31586 ?

guesant avatar Jun 13 '25 20:06 guesant

@guesant - no, its not. This is related to nx using the regular terminal output instead of the tui.

@benwainwright - Hey, thanks for looking through the AI help and confirming things are working when explicitly set. Can you add some console logs into the is-tui-enabled file and determine which check there is returning false? Looking through it on my end there's not an obvious reason that it would default to a different value for you.

AgentEnder avatar Jun 17 '25 15:06 AgentEnder

@AgentEnder it looks like the reason that is-tui-enaabled is returning false is because it thinks my shell is CI.

Image

This is returning true

benwainwright avatar Jun 17 '25 17:06 benwainwright

Ok, after looking into how it worked out something is CI, I had a look through my environment variables. Will you look at that...

Image

Hanging around in my dotfiles, leftover from my time working at the BBC. Happy to consider this closed...

benwainwright avatar Jun 17 '25 17:06 benwainwright

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Jul 18 '25 00:07 github-actions[bot]