warbler
warbler copied to clipboard
taks warble fails on rails 5 because pathname error
When I call Rake::Task[:warble].invoke
from a rake file I get an error:
NoMethodError: protected method `pathmap_replace' called for "public/404.html":String
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/pathmap_helper.rb:15:in `block in apply_pathmaps'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/pathmap_helper.rb:16:in `apply_pathmaps'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/jar.rb:278:in `add_with_pathmaps'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/traits/war.rb:88:in `block in add_public_files'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/traits/war.rb:88:in `add_public_files'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/traits/war.rb:77:in `update_archive'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/traits.rb:41:in `block in update_archive'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/traits.rb:41:in `update_archive'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/jar.rb:181:in `apply_traits'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/jar.rb:159:in `apply'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/task.rb:118:in `block in define_files_task'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/task.rb:94:in `block in define_main_task'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/warbler-2.0.3/lib/warbler/task.rb:93:in `block in define_main_task'
/home/mmonsterkill/projects/terminator_1909/lib/tasks/deploy.rake:13:in `block in (root)'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/railties-5.0.0/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/railties-5.0.0/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/mmonsterkill/.rvm/gems/jruby-9.1.2.0@terminator_1909/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top>'
bin/rails:1:in `<top>'
ruby -v
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 [linux-x86_64]
warble -V
Warbler version 2.0.3
$ rails -V
rake, version 11.2.2
$ rails console
$ "public/404.html".pathmap "%{public/,}p"
=> NoMethodError: protected method `pathmap_replace' called for "public/404.html":String
With rails 4:
ruby -v
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 [linux-x86_64]
warble -V
Warbler version 2.0.3
$ rails -v
Rails 4.2.6
$ rails console
$ "public/404.html".pathmap "%{public/,}p"
=> "404.html"
It seems a weird load path issue or something, I could only figure out that the pathname method is defined in the rake gem and seems to be available in another context between rails 4 and 5.
So I ended up doing this as a workaround:
https://github.com/wintersolutions/warbler/commit/93c6d9e14a696e47d0e25bf9a7039398e238b7e6
Same here.. Rails 5..
I just addded an initializer warbler_fix.rb
with the following content:
class String
public :pathmap_replace
end
Not exactly ideal, but works for me™.