futurism icon indicating copy to clipboard operation
futurism copied to clipboard

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

Open evenreven opened this issue 4 years ago • 6 comments

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/[email protected]
info All dependencies
└─ @stimulus_reflex/[email protected]
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]

evenreven avatar Feb 17 '22 13:02 evenreven

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

julianrubisch avatar Feb 17 '22 13:02 julianrubisch

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

LinuxDevil avatar Jul 28 '22 08:07 LinuxDevil

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.

SpaYco avatar Aug 05 '22 17:08 SpaYco

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 🤞

julianrubisch avatar Aug 05 '22 18:08 julianrubisch

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!

evenreven avatar Aug 08 '22 09:08 evenreven

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

cc @marcoroth

julianrubisch avatar Aug 08 '22 09:08 julianrubisch