suspenders icon indicating copy to clipboard operation
suspenders copied to clipboard

Automate bin/suspenders in development environment without --path

Open thiagoa opened this issue 2 years ago • 0 comments

Some facts:

  • Suspenders includes itself in the generated application's Gemfile
  • Suspenders generators run in the context of the generated applications
  • Generated applications include Suspenders as a development dependency

Given the last item, if we're running Suspenders in development, we'd end up with two copies of it: the development copy and a gem copy. The problem is that:

  • The development copy will start up Suspenders
  • Generators, since they run in the context of an application, will be picked up from the gem

Therefore, running bin/suspenders in development may put us in a situation where the development copy has changes that the gem copy does not, which means our code changes would not fully apply.

To prevent such a mismatch, the existing solution is to run Suspenders with --path, which inserts a path option in the Gemfile:

gem "suspenders", path: "..."

To activate this behavior, running bin/suspenders with a --path option is necessary:

bin/suspenders myapp --path=$HOME/suspenders

That is not an intuitive solution and may trip up developers working on suspenders, which won't always remember to use --path. What if we could infer when to use a path option in the Gemfile by detecting if we're running in development? We can certainly do that.

thiagoa avatar Jul 15 '22 21:07 thiagoa