mruby issue with require and require_relative

2019-08-12 15:18发布

I am trying my hand on with mRuby. I compiled the mRuby source locally. I tried this simple example:

inc.rb

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

test1.rb

require_relative 'inc.rb'

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

end

helloworld('test')

test2.rb

require 'inc.rb'

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

end

helloworld('test')

I executed both the test programs using mruby. mruby.exe test1.rb mruby.exe test2.rb

In both the cases I get the error:

"undefined method 'require_relative' for main (NoMethodError)"

"undefined method 'require' for main (NoMethodError)"

Does mRuby not support 'require'?

标签: mruby
1条回答
别忘想泡老子
2楼-- · 2019-08-12 16:15

mruby doesn't have require functionality. But you can use mruby-require mgem. https://github.com/mattn/mruby-require If you build mruby with mruby-require, then you can use require. require_relative is not supported.

查看更多
登录 后发表回答