dgutov / robe

Code navigation, documentation lookup and completion for Ruby
584 stars 37 forks source link

Non-string path in LOAD_PATH #128

Closed link0ff closed 3 years ago

link0ff commented 3 years ago

When initialization uses such code to add load_path

config.autoload_paths << Rails.root.join('lib')

then among paths that are strings, $LOAD_PATH contains a non-string path such as #<Pathname:./lib>

In this case (robe-request "load_path") in robe-start gets {"path":"./lib"} and returns ("/path/as/string1" "/path/as/string2" ((path . "./lib")) among string paths.

Then file-name-as-directory fails in robe-start with

Debugger entered--Lisp error: (wrong-type-argument stringp ((path . "./lib")))
  file-name-as-directory(((path . "./lib")))
  mapcar(file-name-as-directory
dgutov commented 3 years ago

Hi! Thanks for the report.

The fix should be simple, but how do I repro? So far I've tried

Rails.application.config.autoload_paths += [Rails.root.join('libbb')]

in a sample Rails 5 application, and that value is just not added to $LOAD_PATH. Modifying load path at runtime looks prohibited too: NameError ($LOAD_PATH is a read-only variable).

Which versions of Rails and Ruby are you using?

link0ff commented 3 years ago

Actually it's Rails 4 - a legacy app that soon will be upgraded to Rails 6 :-)

dgutov commented 3 years ago

Ok then, I'll do a test with the closest approximation. :+1: