Mruby-require error: NoMethodError: undefined method 'puts' for main
I managed to compile the mruby code by adding mrubygem - mruby-require from https://github.com/mattn/mruby-require
However, when I try to call 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 that "puts" does not work with mruby. Infact after adding mruby-require gem, ruby ββcode will not be executed. Do I need to add any dependency using mruby-require?
Can anyone help me?
Update: Pasting the contents of build_config.rb as requested. I removed the lines that are commented out.
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
source to share
The following quote is from README.md
:
When using mruby-require, you need to use additional mrbgems that appear after mruby-require in build_config.rb.
This is from your build_config.rb
:
conf.gem 'mrbgems/mruby-require'
conf.gembox 'default'
default
gembox containsmruby-print
. Therefore, it is either required mruby-print
or preferably swapped to make it an inline stone (default behavior without mruby-require
).
source to share