I'm working on a large project with a UI, a Rails API, and some other Rails/Ruby based services located in a monorepo. I'm trying to set up some Rake tasks around Foreman at the root of the project to start up the project in development mode.
The root of the repo contains a Gemfile with Foreman and Rake and a Procfile:
rails-api: sh -c 'cd ./rails-api && bundle && bundle exec rails server'
The rails-api
folder is just a standard Rails 5 API app with its own Gemfile.
When running foreman start
from the repo root, this is the following output:
11:30:10 factory-api.1 | started with pid 38593
11:30:11 factory-api.1 | Using rake 12.3.0
11:30:11 factory-api.1 | Using bundler 1.16.1
11:30:11 factory-api.1 | Using colorize 0.8.1
11:30:11 factory-api.1 | Using dotenv 2.2.1
11:30:11 factory-api.1 | Using thor 0.19.4
11:30:11 factory-api.1 | Using foreman 0.84.0
11:30:11 factory-api.1 | Bundle complete! 4 Gemfile dependencies, 6 gems now installed.
11:30:11 factory-api.1 | Use `bundle info [gemname]` to see where a bundled gem is installed.
11:30:11 factory-api.1 | bundler: failed to load command: rails (/Users/matthew/.rbenv/versions/2.5.0/bin/rails)
11:30:11 factory-api.1 | Gem::Exception: can't find executable rails for gem railties. railties is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
11:30:11 factory-api.1 | /Users/matthew/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/rubygems_integration.rb:458:in `block in replace_bin_path'
11:30:11 factory-api.1 | /Users/matthew/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/rubygems_integration.rb:478:in `block in replace_bin_path'
11:30:11 factory-api.1 | /Users/matthew/.rbenv/versions/2.5.0/bin/rails:23:in `<top (required)>'
11:30:11 factory-api.1 | exited with code 1
11:30:11 system | sending SIGTERM to all processes
As you can see, it's bundling the root Gemfile. Manually bundling from the subfolder works just fine. Even manually executing sh -c 'cd ./rails-api && bundle && bundle exec rails server'
works just fine.
I've also tried throwing a pwd
in the Procfile line and it is returning the subfolder, but bundle
is still running in the root.
Any ideas?