rails / spring

Rails application preloader
MIT License
2.81k stars 341 forks source link

spring binstub modifier does not check for class presence #695

Open jjb opened 1 year ago

jjb commented 1 year ago

thanks for a great project!

The docs say this command bundle exec spring binstub --all should produce this:

begin
  load File.expand_path('../spring', __FILE__)
...

But that's not what i'm seeing in my rails 6.1 app

it simply produced this in bin/rails and bin/rake

 #!/usr/bin/env ruby
+load File.expand_path("spring", __dir__)

it does also generate bin/spring which has some checking logic, so maybe that's the expected behavior and the readme just needs to be updated

if !defined?(Spring)
......

i'm noticing this because i'm running into the problem where

  1. i have spring in development in Gemfile
  2. running something like RAILS_ENV=test rails db:migrate still gives me the Please, set config.cache_classes to false in config/environments/test.rb message

so i'm not sure what is the correct way to not use spring in my local test environment (i think something is happening like, the gem gets installed locally, isn't in the bundle, but the binstub is loading it outside of the logic of bundler?)

jjb commented 1 year ago

this array was generated with "test", which i removed

if !defined?(Spring) && [nil, "development"].include?(ENV["RAILS_ENV"])