Running foreman from a rake task
foreman, rake, ruby, ruby-on-rails, ruby-on-rails-4
Solution
If you must make it work via rake, try changing the shell-out via backtick to use a hard-coded path to the system-wide foreman binary
`/global/path/to/foreman start -f Procfile.dev`
You just need to use 'which' or 'locate' or a similar tool to determine the path that works outside your bundler context. If you are using rbenv, then this might be sufficient :
$ rbenv which rake
/home/name/.rbenv/versions/1.9.3-p448/bin/rake
I hope that helps you move forward.
Problem
I have the following Rake task: ``` namespace :foreman do task :dev do `foreman start -f Procfile.dev` end end desc "Run Foreman using Procfile.dev" task :foreman => 'foreman:dev' ``` The forman command works fine from the shell, however when I run `rake foreman` I get the following error: ``` /Users/me/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/rubygems_integration.rb:240:in `block in replace_gem': foreman is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /Users/me/.gem/ruby/2.0.0/bin/foreman:22:in `<main>' ``` Forman specifically states: ``` Ruby users should take care not to install foreman in their project's Gemfile ``` So how can I get this task to run?