lookbook-hq / lookbook

A UI development environment for Ruby on Rails apps ✨
https://lookbook.build
MIT License
889 stars 91 forks source link

Version requirement for listen gem is not specified, and wrong version error is suppressed #592

Open wheeyls opened 7 months ago

wheeyls commented 7 months ago

If an app has an old version of listen installed, AutoReload stops working with no explanation.

I'm not sure how to fix this right now, but wanted to bring this up as an issue, might open a PR later.

To reproduce, in a Gemfile in a new app:

gem 'listen', '3.4.1'

AutoReload will silently stop working. The reason is that we're catching this error:

can't activate listen (~> 3.5), already activated listen-3.4.1. Make sure all dependencies are added to Gemfile. (Gem::LoadError)

On this line:

https://github.com/ViewComponent/lookbook/blob/8b123bf0ad2dc54e76303381797dd765a8074c7f/lib/lookbook/file_watcher.rb#L19

Could be resolved by letting the error raise? I'm not sure how to resolve an optional dependency.

allmarkedup commented 5 months ago

Hey @wheeyls, thanks for reporting this, and I'm really sorry it has taken so long to reply.

It's a tricky one, I'll try to have a think about the best way to handle it. We can't just let that error raise in way things are currently structured (otherwise apps without the Listen gem installed wouldn't get any file reloading capabilities) but this was always a pretty hacky solution - I'm sure there is a better way to handle it.