lookbook-hq / lookbook

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

ArgumentError: wrong number of arguments (given 0, expected 1..3) #488

Closed guillaumebriday-pa closed 9 months ago

guillaumebriday-pa commented 1 year ago

Describe the bug

My lookbook only works in development env. I follow these instructions https://lookbook.build/guide/installation and it works perfectly but whenever I tried to run in it in test or any other env, I got the error below without any further details.

Any idea why?

Thanks in advance

Screenshots

Screenshot 2023-06-14 at 14 02 52

Version numbers

Please complete the following information:

Additional context

Add any other context about the problem here.

Spone commented 1 year ago

Hi @guillaumebriday-pa! What's at line 7 in your environment.rb?

guillaumebriday-pa commented 1 year ago
# frozen_string_literal: true

# Load the Rails application.
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!  # <-- THIS

So it does not really help me to find the root cause :/

allmarkedup commented 1 year ago

Hey @guillaumebriday-pa, I'm afraid I can't replicate this at all and don't really know how to investigate it any further I'm afraid :(

I realise it's been a long time since you opened this issue and I'm sorry I can be of more help. I'm going to close this issue but if you have any additional info to share that could give me some clues then feel free to reopen it at any time.

guillaumebriday-pa commented 1 year ago

Hi @allmarkedup

I dived into the issue and found something that might help

The problem comes from this line: https://github.com/ViewComponent/lookbook/blob/main/lib/lookbook/engine.rb#L74

Screenshot 2023-09-25 at 12 20 28

For some reasons it only works in development

guillaumebriday-pa commented 1 year ago
Screenshot 2023-09-25 at 12 20 37

Engine.load_previews causes the issue

guillaumebriday-pa commented 1 year ago
Screenshot 2023-09-25 at 12 34 41

And here is the real problem I guess

allmarkedup commented 1 year ago

@guillaumebriday-pa okay thanks for digging into this a bit more.

reloaders.execute should never be called in production, only in development, as there should be no file watching happening in production.

I'm not sure why it would be causing an argument error if it was running but it's worth just making sure that is disabled correctly.

In your config/environments/production.rb file can you try setting the reload_on_change config option to false?

config.lookbook.reload_on_change = false

That setting is not normally needed but it should ensure that the reloaders are not running, even if Lookbook's logic for determining when to watch files is not working in this case.

Could you give that a try and see if that makes any difference?

guillaumebriday-pa commented 1 year ago

It fails even in test, I changed the config

config.lookbook.reload_on_change = false

globally in application.rb and still fails everywhere :/

guillaumebriday-pa commented 10 months ago

Any idea @allmarkedup? 😇

allmarkedup commented 9 months ago

@guillaumebriday-pa I'm sorry but I really don't know what is going on here. I can't replicate it myself and I haven't had any other reports of similar issues.

There may be something unique about your particular setup but I'm not sure how I can really progress this I'm afraid :(

guillaumebriday-pa commented 9 months ago

Ok I fully understand, let's close it for now, I'll reopen it if I find something! 🙏