language-puppet icon indicating copy to clipboard operation
language-puppet copied to clipboard

Ruby function_template not implemented (erb)

Open PierreR opened this issue 8 years ago • 3 comments

Trying to update the puppet-nginx from 0.5 to 0.6 I am stuck with this error:

uncaught throw "Can't call template from a Ruby function, as this will stall (yes it sucks ...)"
/nix/store/54cv11h7acfawqpsyrdky99sk2l50z77-language-puppet-1.3.13-data/share/ghc-8.0.2/x86_64-linux-ghc-8.0.2/language-puppet-1.3.13/ruby/hrubyerb.rb:61:in `throw'
/nix/store/54cv11h7acfawqpsyrdky99sk2l50z77-language-puppet-1.3.13-data/share/ghc-8.0.2/x86_64-linux-ghc-8.0.2/language-puppet-1.3.13/ruby/hrubyerb.rb:61:in `method_missing'
(erb):1:in `get_binding'
/nix/store/b3k7lbdv7xhgp4939519azcndkblidbn-ruby-2.3.4/lib/ruby/2.3.0/erb.rb:864:in `eval'
/nix/store/b3k7lbdv7xhgp4939519azcndkblidbn-ruby-2.3.4/lib/ruby/2.3.0/erb.rb:864:in `result'
/nix/store/54cv11h7acfawqpsyrdky99sk2l50z77-language-puppet-1.3.13-data/share/ghc-8.0.2/x86_64-linux-ghc-8.0.2/language-puppet-1.3.13/ruby/hrubyerb.rb:116:in `runFromContent'
/nix/store/54cv11h7acfawqpsyrdky99sk2l50z77-language-puppet-1.3.13-data/share/ghc-8.0.2/x86_64-linux-ghc-8.0.2/language-puppet-1.3.13/ruby/hrubyerb.rb:112:in `runFromFile'
 in ./modules/nginx/templates/vhost/location.erb at # SourcePos {sourceName = "./modules/nginx/manifests/resource/location.pp", sourceLine = Pos 427, sourceColumn = Pos 26}

The culprit commit is this one.

I guess the template function is not recognized here:

<%= scope.function_template(['nginx/vhost/location_header.erb']) -%>

Is there a easy fix for this a part from ignoring the puppet-nginx altogether ?

Cheers,

PierreR avatar Nov 17 '17 14:11 PierreR

It is recognized, you just can't use it, as it would stall :)

bartavelle avatar Nov 17 '17 15:11 bartavelle

It might be solved by implementing the template function from ruby itself, but I am unsure on how to do that.

bartavelle avatar Nov 17 '17 15:11 bartavelle

As a workaround, is it possible to catch any (ruby) runtime exception that might occur when parsing an erb. When the module is listed as an external modules, an ERROR log statement would be issued instead of an runtime exception.

Does hruby throws a custom haskell exception in order to manage this kind of behavior ?

PierreR avatar Dec 07 '17 19:12 PierreR