Commit 6c77213
Fix: Universal process manager bundler context fallback (#1833)
* Fix foreman execution in bundler context with intelligent fallback
This commit resolves the issue where bin/dev fails when foreman is not included
in the Gemfile (following React on Rails best practices).
The fix implements an intelligent fallback strategy:
1. First attempt: Try running foreman within bundler context
2. Fallback: Use Bundler.with_unbundled_env to run system-installed foreman
3. Enhanced error handling with helpful user guidance
Key improvements:
- Maintains compatibility with projects that include foreman in Gemfile
- Supports React on Rails best practice of system-installed foreman
- Provides clear error messages linking to documentation
- Comprehensive test coverage for all fallback scenarios
Fixes #1832
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Enhance process manager with universal bundler context fallback
This commit generalizes the foreman-specific bundler context fix to work
for ALL process managers (overmind, foreman, and any future additions).
Key improvements:
- Context-aware process detection for all processes, not just foreman
- Universal fallback mechanism using Bundler.with_unbundled_env
- Consistent API with run_process(process, args) for any process manager
- Enhanced test coverage for generalized functionality
Benefits:
- Robust handling of bundler context for any process manager
- Future-proof architecture for new process managers
- Consistent behavior across all system commands
- Eliminates bundler interceptor issues universally
Builds on previous commit to create a comprehensive solution.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Optimize process manager performance and robustness
This commit improves the process manager implementation with several optimizations:
Performance improvements:
- Eliminate redundant system calls in run_process_if_available
- Streamlined control flow with early returns
- More efficient process availability checking
Robustness enhancements:
- Support multiple version flags per process (--version, -v, -V)
- Process-specific version flag mapping for better compatibility
- Improved fallback strategy that avoids double execution
Code quality:
- Cleaner, more readable method structure
- Better separation of concerns
- Enhanced test coverage for version flag handling
- RuboCop compliant code style
The implementation is now more efficient and robust while maintaining
full backward compatibility and comprehensive bundler context handling.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add timeout protection for version checking operations
This commit adds a 5-second timeout to all version checking operations to
prevent the development setup from hanging indefinitely on unresponsive
process managers.
Safety improvements:
- Timeout protection for installed_in_current_context? checks
- Timeout protection for process_available_in_system? checks
- Graceful handling of Timeout::Error alongside Errno::ENOENT
- Prevents hanging development setup on problematic installations
Implementation details:
- Uses Ruby's Timeout module with 5-second limit
- Only applied to version checking, not main process execution
- Main process execution remains unlimited (expected for dev servers)
- Comprehensive test coverage for timeout scenarios
The timeout is conservative (5 seconds) to account for slow systems while
still preventing indefinite hangs that would block developer workflow.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add Bundler API compatibility with DRY helper method
Implement with_unbundled_context helper that supports both modern
(with_unbundled_env) and legacy (with_clean_env) Bundler APIs, with
graceful fallback for very old versions. This addresses backward
compatibility concerns while maintaining clean, DRY code.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add timeout protection for version checking operations
Extract hardcoded timeout value to VERSION_CHECK_TIMEOUT constant for better maintainability and testability.
Co-authored-by: Abanoub Ghadban <[email protected]>
* Apply CodeRabbit review suggestions
- Extract process managers to PROCESS_MANAGERS constant for DRY code
- Relax procfile path validation (remove shell metacharacter check)
- Refactor tests to use around hook with ensure clause for proper cleanup
- Close file descriptors properly to avoid leaks
Co-authored-by: Abanoub Ghadban <[email protected]>
* Revert process_manager.rb changes from commit 5740b0e
- Remove PROCESS_MANAGERS constant (revert to explicit calls)
- Revert procfile validation to stricter shell metacharacter check
- Keep spec file changes from commit 5740b0e (around hook improvements)
Co-authored-by: Abanoub Ghadban <[email protected]>
* Fix RSpec/ExpectOutput violations by removing global stream reassignment
Remove the around hook that was mutating $stdout/$stderr, which triggered
RuboCop's RSpec/ExpectOutput warnings. Tests that need to capture output
already use RSpec's .to output(...).to_stderr matcher correctly.
Co-authored-by: Abanoub Ghadban <[email protected]>
* Update spec/react_on_rails/dev/process_manager_spec.rb
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Remove duplicate RSpec.describe for ProcessManager
---------
Co-authored-by: Claude <[email protected]>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Abanoub Ghadban <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>1 parent 477f17d commit 6c77213
File tree
2 files changed
+306
-40
lines changed- lib/react_on_rails/dev
- spec/react_on_rails/dev
2 files changed
+306
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
38 | 70 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 71 | + | |
44 | 72 | | |
45 | 73 | | |
46 | 74 | | |
47 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
48 | 156 | | |
49 | 157 | | |
50 | 158 | | |
| |||
0 commit comments