-
-
Notifications
You must be signed in to change notification settings - Fork 638
Closed
Description
Problem
The dummy app's bin/dev script fails with the following error when foreman is not included in the Gemfile:
can't find executable foreman for gem foreman. foreman is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
However, running foreman start -f Procfile.dev directly works fine.
Root Cause
- Foreman is intentionally NOT included in the Gemfile (following React on Rails best practices documented in
docs/javascript/foreman-issues.md) - Bundler intercepts system calls when binstubs are active, trying to find foreman within the current bundle context
- The ReactOnRails process manager calls
system("foreman", "start", "-f", procfile)which gets intercepted by bundler
Available Solutions
- Add foreman to Gemfile - Goes against documented best practices
- Use full path to system foreman - Brittle and platform-dependent
- Clear bundle environment - Complex and error-prone
- Use
Bundler.with_unbundled_env- Clean, purpose-built solution
Chosen Solution
Implement a fallback strategy in ProcessManager:
- First attempt: Try running foreman within bundler context (for projects that do include foreman)
- Fallback: Use
Bundler.with_unbundled_envto run system foreman if bundler context fails - Clear error messaging: If foreman isn't found in either context, provide helpful guidance
Implementation Plan
- Modify
lib/react_on_rails/dev/process_manager.rbwith intelligent fallback - Add comprehensive error messaging with links to documentation
- Add tests for the fallback mechanism
- Ensure compatibility with both bundled and system foreman installations
Benefits
- Maintains best practices: Keeps foreman out of Gemfile
- Backwards compatible: Works with projects that do include foreman
- Better UX: Clear error messages guide users to proper setup
- Robust: Handles both bundled and system foreman installations
Metadata
Metadata
Assignees
Labels
No labels