0

I managed to compile the mruby code adding the mrubygem - mruby-require from https://github.com/mattn/mruby-require

However when I try to call the require './' I get an error. Below is my code:

inc.rb

def test(a, b)
    print "Inside the include->test(..)"
    return a+b
end

test1.rb

require 'inc.rb'

def helloworld(var1)
    print 'hello world ' + var1 + ". Test number = " + test(4, 5)

end

helloworld('test')

When I execute test1.rb I get this error from mruby:

NoMethodError: undefined method 'puts' for main

After some analysis I found out the 'puts' is not working with mruby. Infact after adding mruby-require gem, no ruby code gets execute. Do I need to add any dependency with mruby-require?

Can someone help me please?

Update: Pasting the content of build_config.rb as requested. I have removed the lines which are commented.

build_config.rb

MRuby::Build.new do |conf|

  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
    toolchain :visualcpp
  else
    toolchain :gcc
  end

  enable_debug

  # adding the mruby-require library
  conf.gem 'mrbgems/mruby-require'

  conf.gembox 'default'


end

MRuby::Build.new('host-debug') do |conf|

  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
    toolchain :visualcpp
  else
    toolchain :gcc
  end

  enable_debug

  conf.gembox 'default'


  conf.cc.defines = %w(ENABLE_DEBUG)


  conf.gem :core => "mruby-bin-debugger"


end
programmer
  • 582
  • 2
  • 4
  • 16
  • @cremno thanks. This is the only line I added in the build_config.rb conf.gem 'mrbgems/mruby-require' . Let me know if you want me to paste the complete content of build_config.rb, will paste it in the Question part. – programmer Jul 01 '15 at 01:45
  • @cremno, I have updated the Question, pasted the content of `build_config.rb`. I have removed the commented lines to make the content readable. – programmer Jul 01 '15 at 02:01

1 Answers1

3

The following quote is from its README.md:

When mruby-require is being used, additional mrbgems that appear after mruby-require in build_config.rb must be required to be used.

This is from your build_config.rb:

  conf.gem 'mrbgems/mruby-require'

  conf.gembox 'default'

The default gembox contains mruby-print. So either require mruby-print or preferably swap the lines to make it a built-in gem (the default behavior without mruby-require).

cremno
  • 4,672
  • 1
  • 16
  • 27