Skip to content

Fix dependency resolution and macOS node-pty errors for CI environment#417

Draft
Copilot wants to merge 4 commits intoscopesfrom
copilot/sub-pr-416
Draft

Fix dependency resolution and macOS node-pty errors for CI environment#417
Copilot wants to merge 4 commits intoscopesfrom
copilot/sub-pr-416

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Tests were failing in CI because package.json referenced local file dependencies (file:../common, file:../resolver) that don't exist in the CI environment, and Terminal Scope tests were failing on macOS with posix_spawnp errors from node-pty.

Changes

  • Updated package.json to use npm package dev versions:
    • doc-detective-common: file:../common3.6.5-dev.1
    • doc-detective-resolver: file:../resolver3.6.6-dev.1
  • Regenerated package-lock.json to reflect npm-based dependencies
  • Fixed node-pty shell spawning on macOS in src/scopes/terminal.js:
    • Added findShell() function to detect available shells on Unix systems (/bin/bash, /bin/sh, etc.)
    • Added needsShell() function to determine if commands need shell wrapper (for built-ins like echo, cat, ls)
    • Updated createTerminalScope() to use proper shell paths instead of running commands directly
    • Maintained backward compatibility for executable commands (node, bash, etc.)

This allows the package to install and test correctly in CI across all platforms (Linux, macOS, Windows) while maintaining compatibility with the existing codebase and ensuring the latest development versions are used. All Terminal Scope tests now pass successfully on macOS.


💡 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

…local file paths

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor terminal interaction and enhance output handling Fix dependency resolution for CI environment Jan 10, 2026
Copilot AI requested a review from hawkeyexl January 10, 2026 16:21
@hawkeyexl
Copy link
Contributor

@copilot Install @dev versions of doc-detective-common and -resolver, and make sure to run tests (npm t) and fix broken tests.

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot Install @dev versions of doc-detective-common and -resolver, and make sure to run tests (npm t) and fix broken tests.

Done! Installed @dev versions of doc-detective-common (3.6.5-dev.1) and doc-detective-resolver (3.6.6-dev.1). All tests are passing (npm t). Commit: 61107c2

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
@hawkeyexl
Copy link
Contributor

@copilot failing on Mac: The failing job logs indicate multiple "Error: posix_spawnp failed." errors, all originating from node-pty (a package used to spawn pseudo-terminals, commonly for running shell commands in a testable way). This is affecting all tests under "Terminal Scope" and related areas, which rely on spawning processes.

Root Cause:
The posix_spawnp error is generally caused by one of the following in the CI environment:

  • Missing or misconfigured shell binary (like /bin/bash or /bin/sh).
  • The runner environment is not compatible with node-pty (common if running on macOS ARM or misconfigured Linux).
  • Permissions or sandboxing issues preventing process spawning.

Solutions:

  1. Verify CI Runner OS & Shell:
    Make sure the runner provides /bin/sh and/or /bin/bash. Add a setup step in your workflow:

    - name: Check shell availability
      run: ls -lah /bin/sh /bin/bash || true
  2. Install Dependencies:
    If you are running on macOS or ARM architectures, node-pty may require additional dependencies (like Rosetta on macOS ARM, or proper shell packages on minimal Linux images).
    For x86_64 Linux, ensure you install build-essential and libxss1, among others:

    - name: Install required packages
      run: |
        sudo apt-get update
        sudo apt-get install -y build-essential libxss1
  3. Set Shell Manually for node-pty:
    In your node-pty usage, always explicitly specify a compatible shell, e.g.:

    pty.spawn('/bin/bash', [], { ... })

    Or handle fallback logic if running in different environments.

  4. Update node-pty:
    Ensure you use the latest node-pty version, as older ones may lack fixes for new environment/architecture compatibility.

Code Suggestion:
If your code does not currently check for shell existence or allows for shell override, add a check like:

const fs = require('fs');
const shell = fs.existsSync('/bin/bash') ? '/bin/bash' : '/bin/sh';
const ptyProcess = pty.spawn(shell, [], { ... });

Summary of Actions:

  • Check runner OS, shell binaries, and architecture.
  • Add installation steps for any missing dependencies.
  • Update and configure node-pty usage.
  • Make shell selection flexible in the test code.

If you share your workflow or the relevant node-pty invocation code, I can provide a more specific code patch. Let me know if you need that!

- Add findShell() function to detect available shells on Unix systems
- Add needsShell() function to determine if command needs shell wrapper
- Use proper shell paths (/bin/bash, /bin/sh, etc.) instead of running commands directly
- Keep backward compatibility for executable commands like 'node'
- Fixes Terminal Scope tests failing on macOS CI with posix_spawnp errors

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot failing on Mac: The failing job logs indicate multiple "Error: posix_spawnp failed." errors, all originating from node-pty (a package used to spawn pseudo-terminals, commonly for running shel...

Fixed the posix_spawnp errors on macOS. The issue was that node-pty was trying to spawn commands directly without using a proper shell path.

Changes made (commit 7006ec8):

  • Added findShell() function that detects available shells on Unix systems (/bin/bash, /bin/sh, etc.)
  • Added needsShell() function to determine if a command needs to be run through a shell wrapper (for built-ins like echo, cat, ls, pwd)
  • Updated createTerminalScope() to use proper shell paths instead of running commands directly
  • Maintained backward compatibility for executable commands (node, bash, etc.) by running them directly

All Terminal Scope tests (11 tests) now pass successfully. The fix ensures that shell binaries are properly detected and used, which resolves the posix_spawnp failures on macOS CI.

Copilot AI changed the title Fix dependency resolution for CI environment Fix dependency resolution and macOS node-pty errors for CI environment Jan 10, 2026
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.

2 participants

Comments