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

Running installer on clean Rails 5.2 fails with TypeError: no implicit conversion of nil into String #133

Open
evenreven opened this issue Feb 17, 2022 · 6 comments

Comments

@evenreven
Copy link

Bug Report

I'm trying to add Futurism to a legacy Rails app running Rails 5.2, and I'm running into problems. Trying to recreate in a new 5.2 app has the same issues.

Describe the bug

Running bin/rails futurism:install --trace gives this error:

Trace
** Invoke futurism:install (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute futurism:install
yarn add v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ @stimulus_reflex/futurism@1.2.0-pre9
info All dependencies
└─ @stimulus_reflex/futurism@1.2.0-pre9
Done in 2.67s.
Updating
rails aborted!
TypeError: no implicit conversion of nil into String
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/futurism-1.1.0/lib/tasks/futurism_tasks.rake:19:in `initialize'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/futurism-1.1.0/lib/tasks/futurism_tasks.rake:19:in `open'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/futurism-1.1.0/lib/tasks/futurism_tasks.rake:19:in `block (2 levels) in <main>'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/user/.rbenv/versions/2.6.9/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.2.6.2/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.2.6.2/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.2.6.2/lib/rails/command.rb:48:in `invoke'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.2.6.2/lib/rails/commands.rb:18:in `<main>'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/user/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => futurism:install

To Reproduce

Create a new Rails 5.2 install with actioncable, then bundle add futurism and bin/rails futurism:install

Expected behavior

I expected it to install, or to give an error message with more information on what went wrong.

Screenshots or reproduction

[see above]

Versions

Futurism

  • Gem: 1.1.0
  • Node package: 1.2.0-pre9

External tools

  • Ruby: 2.6.9
  • Rails: 5.2.6.2
  • CableReady: 4.5.0
  • Node: 14.19.0

Browser

[not applicable]

@julianrubisch
Copy link
Contributor

Thanks for the report! Will try to get behind what's wrong

@LinuxDevil
Copy link

@julianrubisch Hey! Did you found out what happened? (Trying to solve it)

@SpaYco
Copy link

SpaYco commented Aug 5, 2022

https://github.com/stimulusreflex/futurism/blob/master/lib/tasks/futurism_tasks.rake#L8-L13

This is not covering all of the possible locations the file could be, it either needs more paths or simply ask for user input if no file was found.

I fixed the issue by manually adding the file path (app/javascript/application.js).

I would still advise doing a manual installation because this auto-install is assuming some stuff, which might not be the case for everyone.

@julianrubisch
Copy link
Contributor

In fairness, this was all written before importmaps-rails, jsbundling-Rails etc.

we‘re just in the process of streamlining all StimulusReflex and CableReady installers, futurism will come next 🤞

@evenreven
Copy link
Author

Nice find @SpaYco, I was looking in the wrong place. I guess this is the root of my issue? Rails 5.2 didn't use Webpacker by default, so app/javascript doesn't exist unless you install it manually. And my legacy Rails app actually has been retrofitted to use vite_rails, which encourages using app/frontend/entrypoints. Any chance this gem's installer could be less opinionated about this, @julianrubisch? I'm not asking that you should cover every edge case, but maybe a prompt if the standard locations aren't found? Thanks!

@julianrubisch
Copy link
Contributor

It definitely should and will. We’re just trying to reuse as much as possible between CR, SR, futurism and others

cc @marcoroth

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

4 participants