Rexml/document with IronRuby

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 . . .

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

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.

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

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

JD

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

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. <

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.

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

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 :frowning:

Cheers, Orion

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.

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

You can add load paths too from C#

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
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

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

API.

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Orion E.
Sent: Friday, January 15, 2010 9:47 PM
To: [email protected]
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 :frowning:

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