Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polaris View Components view helper problem #200

Open
resistorsoftware opened this issue Feb 11, 2022 · 7 comments
Open

Polaris View Components view helper problem #200

resistorsoftware opened this issue Feb 11, 2022 · 7 comments

Comments

@resistorsoftware
Copy link
Contributor

resistorsoftware commented Feb 11, 2022

Rails 7.0.2, Ruby 3.1.0

This App was great a few hours ago, I added a new gem to my bundle and boom, all borked now.

Tried running a generator and it did not like something:

rails g mailer order_export
`Redis.current=` is deprecated and will be removed in 5.0. (called from: /Users/tipjar/Documents/Workspace/Apps/reglisse/config/initializers/redis.rb:3:in `<main>')
/Users/tipjar/.rvm/gems/ruby-3.1.0/bundler/gems/polaris_view_components-e379a8d7e236/lib/polaris/view_components /engine.rb:39:in `block (2 levels) in <class:Engine>': uninitialized constant Polaris::ViewHelper (NameError)

      helper Polaris::ViewHelper
                    ^^^^^^^^^^^^

Next up, I just tried running the App, and strangely it won't run at all now. Same error.

I figured I would ask the great Zeitwerk what he thought.. and he bubbled too.

rails zeitwerk:check
`Redis.current=` is deprecated and will be removed in 5.0. (called from: /Users/tipjar/Documents/Workspace/Apps/reglisse/config/initializers/redis.rb:3:in `<main>')
rails aborted!
NameError: uninitialized constant Polaris::ViewHelper

      helper Polaris::ViewHelper
                    ^^^^^^^^^^^^
/Users/tipjar/Documents/Workspace/Apps/reglisse/config/environment.rb:5:in `<main>'
Tasks: TOP => zeitwerk:check => environment
(See full trace by running task with --trace)

So suddenly, the engine is having problems autoloading code? It was working perfect today! No issues. I added one gem and bundled that in, and boom. No more Polaris View Components? I see nothing wrong in the code in the engine.

What the heck... my other Rails 7.0.1 project works perfect... with the same code pretty well, but a Polaris View Component I pulled from the 8.0 main branch, not 8.1. Should not have made a stitch of difference.

@resistorsoftware resistorsoftware changed the title Running generator now throws errors Polaris View Components view helper problem Feb 11, 2022
@cmwoodal
Copy link

I'm attempting to use this gem for the first time and have encountered the same issue as presented above.

@resistorsoftware can you share any information about how you were able to resolve this issue?

I'm currently running rails 7.0.3 on ruby 3.1.2.

thanks in advance

@resistorsoftware
Copy link
Contributor Author

I don't remember exactly, but this was not a Polaris View Component problem, but instead a Rails one. I think I just had to adjust my gems to get it all working.

@aldrienht
Copy link

aldrienht commented Nov 20, 2024

Hi guys, I also having this issue - could you please share the workaround you'd made before. Thanks!

I'm using
Rails 7.0.8.6
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin24

gem 'polaris_view_components', '~> 2.0', '>= 2.0.1'
gem "view_component"

10:45:30 web.1     | Puma starting in single mode...
10:45:30 web.1     | * Puma version: 5.6.5 (ruby 3.1.0-p0) ("Birdie's Version")
10:45:30 web.1     | *  Min threads: 2
10:45:30 web.1     | *  Max threads: 2
10:45:30 web.1     | *  Environment: development
10:45:30 web.1     | *          PID: 36875
10:45:32 web.1     | ! Unable to load application: NameError: uninitialized constant Polaris::ViewHelper
10:45:32 web.1     | 
10:45:32 web.1     |           helper Polaris::ViewHelper
10:45:32 web.1     |                         ^^^^^^^^^^^^

@aldrienht
Copy link

aldrienht commented Nov 20, 2024

Looks like the latest version of this gem is for Rails 7.1 or higher https://github.com/baoagency/polaris_view_components/pull/338/files
Also needs higher than ruby 3.1 🤔

@kirillplatonov
Copy link
Collaborator

I'm gonna double check it on Rails 7.0

@remy727
Copy link
Contributor

remy727 commented Nov 24, 2024

Our app runs on rails 7.0.8.4 and ruby 3.1.2. We don't have any issues.

@resistorsoftware
Copy link
Contributor Author

Can confirm Rails 7.1.5 at Ruby 3.3.6 works fine, and once again, this is a thing I am almost certain was just an unfortunate bundle, whereby I used the Zeitwerk and eventually figured out that it was just a bad bundle. A Ruby issue that was fixed by carefully removed the lockfile and just starting over with fresh bundles... I know that sounds non-technical, but the clue for me was that adding a gem should not suddenly start blowing chunks at Polaris::Viewhelper.

So while I cannot remember the exact cure, I swear it was nothing more than making sure all my gems made sense, doing a fresh bundle install, and voila, all worked again without any changes...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants