I’m trying to write to an XML file using Builder but cannot seem to find Builder when I start up my program. I installed it using gem install builder and then used the following in my file, but it does not start up:
require 'rubygems'
require_gem 'builder'
def product_xml
builder = Builder::XmlMarkup.new("", 2)
puts builder.person {
name("Selene")
id("1")
x("2");
y("3");
}
end
The error that I am getting is:
LoadError: no such file to load -- rubygems
require at org/jruby/RubyKernel.java:1038
(root) at C:\Users\Ron\Dropbox\...\server\.\data\plugins\cmd-dev\dev.r
b:2
To install gems inside the JRuby enviroment you must use
jruby -S gem, not justgem(if you are not using RVM).So you should install Builder with
jruby -S gem install builder. Once you have installed it, you should just userequire 'builder', notrequire_gem 'builder'.