Skip to content

Catch MissingSpecError when spring not installed

What does this MR do and why?

This change updates bin/spring to gracefully handle if the spring gem is not installed and improves the user experience:

Current

$ bin/spring stop
Traceback (most recent call last):
	3: from bin/spring:14:in `<main>'
	2: from /Users/ash/.asdf/installs/ruby/2.7.7/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
	1: from /Users/ash/.asdf/installs/ruby/2.7.7/lib/ruby/site_ruby/2.7.0/rubygems/dependency.rb:323:in `to_spec'
/Users/ash/.asdf/installs/ruby/2.7.7/lib/ruby/site_ruby/2.7.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'spring' (= 4.1.0) among 1053 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/ash/.asdf/installs/ruby/2.7.7/lib/ruby/gems/2.7.0:/Users/ash/.gem/ruby/2.7.0' , execute `gem env` for more information

With the fix

$ bin/spring stop
INFO: Spring not available.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Ash McKenzie

Merge request reports

Loading