Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 8, 2025

Overview

This PR implements warning messages for shell initialization failures and version checks for Node.js and Python environments as requested in issue #[issue_number].

When shell initialization steps fail or environment versions don't match expectations, users now receive clear warnings on stderr to help diagnose configuration issues.

Changes

Warning System

Added a new _dots_warn() helper function that outputs warnings to stderr with a "WARNING:" prefix:

_dots_warn() {
    echo "WARNING: $*" >&2
}

Enhanced Initialization Functions

NVM (_dots_load_nvm())

  • Warns when nvm.sh is missing or fails to load
  • Warns when bash completion fails to load
  • Only warns about missing Node.js when nvm is successfully loaded

Pyenv (_dots_load_pyenv())

  • Warns when pyenv is not found in PATH
  • Warns when pyenv initialization fails

Homebrew (_dots_load_brew())

  • Warns when homebrew initialization fails

Version Checks

Node.js Version Check

  • Compares current Node.js version against expected version from nvm alias file (lts/jod)
  • Handles version strings with or without 'v' prefix
  • Only checks when nvm is available (avoids false positives)

Python Version Check

  • Compares current Python version against expected version (3.13.7)
  • Checks both python and python3 commands
  • Only checks when pyenv is available (avoids false positives)

Example Output

# System without nvm/pyenv installed:
WARNING: pyenv not found in PATH

# System with version mismatch:
WARNING: Node.js version mismatch: current=v18.0.0, expected=v20.11.0
WARNING: Python version mismatch: current=3.12.3, expected=3.13.7

# System with missing nvm.sh:
WARNING: nvm.sh not found at /home/user/.nvm/nvm.sh

Technical Details

  • All warnings go to stderr - Allows proper separation from stdout and can be redirected independently
  • POSIX-compatible syntax - Uses case statements and >/dev/null 2>&1 for maximum shell compatibility
  • Smart detection - Contextual warnings only appear when tools should be present
  • Proper cleanup - Variables are unset appropriately to avoid errors
  • No breaking changes - Maintains full backward compatibility

Testing

  • ✅ Verified warnings appear correctly on stderr
  • ✅ Tested with bash and sh shells
  • ✅ Confirmed environment setup continues to work despite warnings
  • ✅ Tested version mismatch detection
  • ✅ Verified POSIX compatibility

Benefits

Users can now:

  • Quickly identify shell initialization failures during login
  • Detect when Node.js or Python versions don't match expected versions
  • Redirect warnings to a log file for debugging: bash -l 2>/tmp/shell-warnings.log
  • Hide warnings when needed: bash -l 2>/dev/null
  • See all warnings with: bash -l 2>&1 | grep WARNING

This helps maintain a healthy development environment and makes it easier to troubleshoot configuration issues.

Original prompt

This section details on the original issue you should resolve

<issue_title>Login shell environment checks</issue_title>
<issue_description>Print a warning message if any of the shell initialisation steps fail. Perform a quick check for the standard node/python environment versions and print a warning if they are not up-to-date</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #63

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add shell environment checks with version warnings Add login shell environment checks with warnings for initialization failures and version mismatches Oct 8, 2025
Copilot AI requested a review from andrejusk October 8, 2025 13:46
@andrejusk andrejusk marked this pull request as ready for review October 8, 2025 14:28
@andrejusk andrejusk force-pushed the copilot/add-shell-environment-checks branch from 3f35056 to 09c6415 Compare October 8, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Login shell environment checks

2 participants