mruby-require error: NoMethodError: undefined method 'puts' for main

mruby-require error: NoMethodError: undefined method 'puts' for main

我设法编译了 mruby 代码,添加了 mrubygem - mruby-require from https://github.com/mattn/mruby-require

但是,当我尝试调用 require './' 时,出现错误。下面是我的代码:

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')

当我执行 test1.rb 时,我从 mruby:

得到这个错误
NoMethodError: undefined method 'puts' for main

经过一些分析,我发现 'puts' 不适用于 mruby。事实上,在添加 mruby-require gem 之后,没有 ruby 代码被执行。我是否需要使用 mruby-require 添加任何依赖项?

有人可以帮我吗?

更新:按要求粘贴build_config.rb的内容。我已经删除了评论的行。

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

以下引自其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.

这是来自你的 build_config.rb:

  conf.gem 'mrbgems/mruby-require'

  conf.gembox 'default'

The default gembox contains mruby-print。因此,要么需要 mruby-print,要么最好交换行以使其成为内置的 gem(没有 mruby-require 的默认行为)。