0

I have a stumbled block with the following errors on Ubuntu Server 16.04 with Ruby and MRuby installed, what is the cryptic error that is missing?

Hiredis is installed and compiled with H2O (latest 2.3), the error is still persist, I have no experience in Ruby and google for solutions didn't help.

Updated: I have replaced with simple code to simplify the problem.

$ ruby app/json_api.rb 
$ mruby app/json_api.rb 

Source code:

 class JsonApi
  def initialize
    @storage = Hiredis.new
    @storage['foo'] = 'bar'
  end

  def call(env)
    body = JSON.generate({foo: @storage['foo']})

    [
      200,
      {'Content-Type'   => 'application/json',
       'Content-Length' => body.size},
       [body]
    ]
  end
end

JsonApi.new
James Lei
  • 340
  • 2
  • 5
  • 15
  • That error tells me that the `MRuby` namespace/class isn't defined anywhere. Are you requiring a another Ruby file with the namespace/class name of `MRuby`? – Zach Tuttle Mar 01 '18 at 18:37
  • How do Ruby/MRuby define namespace or similarly? I have the same NamedError when running the code from this repo. Does it require to define any paths to bash? https://github.com/jodosha/mruby-rack-json-api/blob/master/app/json_api.rb – James Lei Mar 01 '18 at 18:49
  • I think in order to utilize the `Hiredis` class you need to require it. If your using mruby you might need to use something like this: https://github.com/mattn/mruby-require to get the ruby like requires to work in mruby. Take a look at this as well https://github.com/mruby/mruby/blob/master/doc/guides/mrbgems.md. – Zach Tuttle Mar 01 '18 at 19:08
  • Also this might help to to put the mruby configuration into perspective on how its supposed to be used: https://translate.google.com/translate?hl=en&sl=ja&u=https://qiita.com/masuidrive/items/e516c23b4feab73d139f&prev=search – Zach Tuttle Mar 01 '18 at 19:21

0 Answers0