# Rexml/document with IronRuby

**URL:** <https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668>\
**Category:** IronRuby\
**Created:** [January 15, 2010, 6:35pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668 "2010-01-15T18:35:09Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 6:35pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/1 "2010-01-15T18:35:09Z")

</div>

Is rexml/document compatible with IronRuby? I am running the following  
code:  
and it throws me the exception:

require ‘rexml/document’

include REXML

class EnvironmentSetupService

def setupEnvironment(connectionString)

# open the file

file = File.open(’…/…/Web.config’,‘w+’)  
doc = Document.new(file)

puts doc.root

end  
end

Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load  
– rexml/  
document  
at  
Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame  
fram  
e)  
at  
Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(InterpretedFra  
me frame)  
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame  
frame)  
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0  
arg0, T1 a  
rg1)  
at IronRuby.Runtime.RubyScriptCode.Run(Scope scope, Boolean  
bindGlobals)  
at IronRuby.Runtime.RubyScriptCode.Run(Scope scope)  
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink  
errorSink)  
at Microsoft.Scripting.SourceUnit.Execute(Scope scope)  
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope  
scope)  
at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path,  
ScriptSc  
ope scope)  
at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path)  
at ConsoleApplication2.Program.Main(String[] args) in  
C:\Projects\EStudyVS200  
8\EStudySoltution\EStudy\ConsoleApplication2\Program.cs:line 18  
Press any key to continue . . .

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 7:12pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/2 "2010-01-15T19:12:45Z")

</div>

> Is rexml/document compatible with IronRuby?

Yes:

> > > require ‘rexml/document’  
> > > =\> true

What is the value of $LOAD\_PATH? I had sent you a mail earlier saying to  
copy ir.exe.config and put it in your application’s app.config, and to  
correct any relative paths in the LibraryPaths value. Not being able to  
find rexml means that the Ruby standard library isn’t on your  
$LOAD\_PATH, or your application doesn’t have permissions to see it.

If you have questions about a library being supported, please try it  
through ir.exe; if it works then you know it’s a problem with your  
hosting setup.

~Jimmy

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 7:19pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/3 "2010-01-15T19:19:46Z")

</div>

I thought this path mess was cleaned in the IronRuby RC version. I have  
the “bin” folder path in my environment variable.

I can execute the ruby implemention of the rexml/document without any  
problems. But when I try to do the same using C# invoking IronRuby it  
throws exceptions.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 7:43pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/4 "2010-01-15T19:43:56Z")

</div>

Will this be changed in the final release!! This configuration, setting  
different paths etc is too much a hassle for developers.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 7:40pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/5 "2010-01-15T19:40:51Z")

</div>

Even with the release version, you need to make your app.exe.config have  
the right xml elements to setup the load path.

JD

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 8:11pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/6 "2010-01-15T20:11:53Z")

</div>

> This configuration, setting different paths etc is too much a hassle for developers.

Let’s go over what “configuration, setting different paths etc” actually  
means:

- When using ir.exe directly?

- When embedding IronRuby inside a .NET app?

And that’s it. So please, let me know how this could be too much hassle  
for you.  
Sure, embedding isn’t “one-click”, but don’t blow it up to be more than  
it really is.  
Please let us know if you’ve found any real ship-stopping bugs.

Note that ir.exe.config uses relative paths as we have no idea where  
someone will  
unzip the release to. With the MSI we can possibly generate  
ir.exe.config to use  
full paths, but that would be very low on our list of stuff to do for  
1.0. Also,  
if we release VS integration in the future, generating the correct  
app.config  
for embedding is also a possibility.

However, for embedding, presumably you are going to want to put the  
libraries  
into your application’s directory, so you do really care about where the  
paths  
are, which is why we don’t somehow magically find them.

~Jimmy

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 8:38pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/7 "2010-01-15T20:38:13Z")

</div>

To further the point, adding elements to your config should be a fairly  
routine task, as it is also required by data access, WCF, and other  
libraries. Some of those may have tooling, but you must edit the config  
in  
some way. So I don’t see this as quite an incredulous thing to ask.

Ryan R.

On Fri, Jan 15, 2010 at 1:09 PM, Jimmy S. \<

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 8:59pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/8 "2010-01-15T20:59:23Z")

</div>

When I presented on IronRuby at different events and showed people how  
much they have to do in order to get the thing in working state they  
nudge their head and says no thanks.

Developers are already drained under configuration and now they have to  
remember this one more configuration.

Setting up environment variables, pasting code from ir.exe.config into  
personal config settings. This is too much work for a developer. Not to  
mention that this has to be done on every dev machine.

Yes, I can make a batch file which can inject the settings into  
environment and config but then this is another thing to maintain and  
dev nightmare.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 16, 2010, 6:49am UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/9 "2010-01-16T06:49:20Z")

</div>

The worst thing about WCF is all the configuration! Just because  
everything else sucks it doesn’t mean that it’s ok for us to suck too!

At least you can configure WCF programatically. Along the same lines, it  
would be nice for IronRuby to offer a programmatic option also (if it  
already does, then hooray!)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 16, 2010, 6:52am UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/10 "2010-01-16T06:52:16Z")

</div>

While I agree that changing the app.config is a common task, and it’s  
easy if you’re just shipping a single standalone app, it’s a giant pain  
in the ass if you’re having to upgrade an existing installation, or  
integrate with another program. (Outlook.exe.config anyone??)  
I’ve seen a fair few .net apps move their configuration OUT of  
app.config and into the registry because of things like that.

Is there a way that we can set the library path and other such things  
programatically (eg: RubyEngine.LoadPath = “blah”), etc? That would be  
much nicer than app.config mangling ☹

Cheers, Orion

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 15, 2010, 9:04pm UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/11 "2010-01-15T21:04:36Z")

</div>

BTW,

I like to mention that I love IronRuby. The above post is the feedback I  
received from the audience who were in my “I Love IronRuby” session.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 16, 2010, 8:03am UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/12 "2010-01-16T08:03:39Z")

</div>

You can change all that from code as well.  
ScriptRuntimeSetup is what you’re interested in

> <https://github.com/casualjim/ironrubymvc/blob/master/IronRubyMvc/Core/RubyEngine.cs#L412>

You can add load paths too from C#

> <https://github.com/casualjim/ironrubymvc/blob/master/IronRubyMvc/Core/RubyEngine.cs#L365>

Adding stuff to the registry is always wrong IMO. The reason being that  
the  
registry only exists on windows and maybe for you that isn’t a problem.  
In  
european governments it’s not allowed to use windows for many of the  
applications (I’m sure most of you know about the great relationship  
between  
the EU and MSFT) so they run linux with mono. In my country that  
amounts to  
about 30% of the entire IT infrastructure/employment. The config  
problem is  
a trivial problem at best, and I don’t think this issue is ironruby  
specific.

Deploying stuff with registry keys almost forces you to use an  
installer,  
which makes the process of scripting the installation of an entire  
environment less than optimal for example ( I don’t do system images  
because  
they get stale and are bound to specific hardware).

I could do a long rant on this subject, but in comparison to 95% of the  
software I get to deal with in an enterprise environment has at least 5x  
the  
configuration requirements from IronRuby. Let’s look at this closer  
this  
whole thread is about \< 10 f’ing lines of XML.

Less than 10 lines people, have you ever set up  
asp.netmvc/WCF/windsor/unity/…? So I think instead of complaining  
you should be  
happy with what the IronRuby team accomplished.  
Would you rather have the default values hard-coded then, because that’s  
such a great solution ?

\<microsoft.scripting\>

```
<options>
  <set language='Ruby' option='LibraryPaths'

```

value=‘…\lib\IronRuby;…\lib\ruby\site\_ruby\1.8;…\lib\ruby\site\_ruby;…\lib\ruby\1.8’/\>  
  
\</microsoft.scripting\>

* * *

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [January 16, 2010, 8:14am UTC](https://www.ruby-forum.com/t/rexml-document-with-ironruby/181668/13 "2010-01-16T08:14:11Z")

</div>

BTW: I don’t see how moving configuration from .config file to registry  
helps anything. There is an API for updating .config files as there is  
an API for updating registry.  
When integrating with another .NET program you just insert IronRuby/DLR  
specific section into the existing .config file and you’re done. Outlook  
isn’t a managed app and thus hosts CLR via native hosting APIs. In that  
case it’s up to the host how it manages configuration. You can always  
load a configuration file yourself if the host doesn’t do it for you.  
See

> **[ConfigurationManager Class (System.Configuration)](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager?view=dotnet-plat-ext-7.0&redirectedfrom=MSDN)**
>
> Provides access to configuration files for client applications. This class cannot be inherited.

API.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Orion E.  
Sent: Friday, January 15, 2010 9:47 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] rexml/document with IronRuby

While I agree that changing the app.config is a common task, and it’s  
easy if you’re just shipping a single standalone app, it’s a giant pain  
in the ass if you’re having to upgrade an existing installation, or  
integrate with another program. (Outlook.exe.config anyone??)  
I’ve seen a fair few .net apps move their configuration OUT of  
app.config and into the registry because of things like that.

Is there a way that we can set the library path and other such things  
programatically (eg: RubyEngine.LoadPath = “blah”), etc? That would be  
much nicer than app.config mangling ☹

Cheers, Orion

On 16/01/2010, at 8:09 AM, Jimmy S. wrote:

This configuration, setting different paths etc is too much a hassle for  
developers.

Let’s go over what “configuration, setting different paths etc” actually  
means:

- When using ir.exe directly?

Nothing, the Ruby standard library just works.

- When embedding IronRuby inside a .NET app?

Just telling your C# app where IronRuby’s libraries are:

1. Copy ir.exe.config into your app.config
2. Make sure LibraryPaths still make sense. Making these full-paths is  
easiest,  
So just replace the “…” with “C:\IronRuby” (or wherever you  
extracted a IronRuby  
release to … for example this is the LibraryPaths for a  
C:\IronRuby installation:  
C:\IronRuby\lib\IronRuby;C:\IronRuby\lib\ruby\site\_ruby\1.8;C:\IronRuby\lib\ruby\site\_ruby;C:\IronRuby\lib\ruby\1.8

And that’s it. So please, let me know how this could be too much hassle  
for you.  
Sure, embedding isn’t “one-click”, but don’t blow it up to be more than  
it really is.  
Please let us know if you’ve found any real ship-stopping bugs.

Note that ir.exe.config uses relative paths as we have no idea where  
someone will  
unzip the release to. With the MSI we can possibly generate  
ir.exe.config to use  
full paths, but that would be very low on our list of stuff to do for  
1.0. Also,  
if we release VS integration in the future, generating the correct  
app.config  
for embedding is also a possibility.

However, for embedding, presumably you are going to want to put the  
libraries  
into your application’s directory, so you do really care about where the  
paths  
are, which is why we don’t somehow magically find them.

~Jimmy
