UncleGene / flay-actionpack

Flay your rails ERB
MIT License
4 stars 2 forks source link

Merely adding the gem doesn't appear to be enough #4

Open hakanai opened 1 year ago

hakanai commented 1 year ago

I have a project where flay is failing on Rails ERb files.

So I added

gem 'flay-actionpack'

to Gemfile, but it still failed to parse ERb files.

Investigating with ruby -d, Bundler appears to be trying to load:

But the actual file is 'flay_actionpack.rb' so neither of those is going to work.

The code in Bundler responsible for this is: https://github.com/rubygems/bundler/blob/master/lib/bundler/runtime.rb#L65-L94

Clearly it must have worked at some point in the past, so my guess is that perhaps Bundler changed its mind on what separators it was going to permit?

hakanai commented 1 year ago

Okay, having dug a bit deeper now... flay loads the plugins explicitly itself, so whether the file is required by bundler or not is irrelevant.

But what's happening is - flay gets a list of the files containing plugins. This contains:

Because their plugins comes after flay_actionpack, anything flay_actionpack does to try and override erb behaviour will be stomped by the base one which errors out on Rails erb files.

Given that gem is not respecting the order the gems are required in the Gemfile, I'm not sure what I can do to work around this one.

hakanai commented 1 year ago

There's this line:

https://github.com/UncleGene/flay-actionpack/blob/master/lib/flay_actionpack.rb#L6

Which at first glance seems like it might be there to work around this issue. But at the time the plugin loads the value in @@plugins is [], so nothing happens.

If instead it appended it to the list, then it might make everything work? That's the only theory I've got.