Forum: IronRuby ironruby in and rubygems

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Andreas Beck (Guest)
on 2012-01-29 21:30
(Received via mailing list)
I've just encountered the following problem:
I've installed the gem "builder" in version 2.0 via igem and it works
When using it in a script first the first 2 lines are:

    require 'rubygems'
    require 'builder'

In I execute ruby code in the following way:

I linked:


from InstallationDirectory\Silverlight\bin\

my code which works fine with "regular" ruby code:

    Sub Main(ByVal Args As String())
        Dim rubyRuntime As Microsoft.Scripting.Hosting.ScriptRuntime
        Dim rubyEngine As Microsoft.Scripting.Hosting.ScriptEngine

        rubyRuntime = IronRuby.Ruby.CreateRuntime
        rubyEngine = rubyRuntime.GetEngine("rb")

        Dim strRuby As String

        Dim fileReader As StreamReader
        fileReader = New
StreamReader(System.Environment.CurrentDirectory &
"\" & Args(0))
        strRuby = fileReader.ReadToEnd
        fileReader = Nothing
    End Sub

Now, when I compile the code the libraries I linked are copied in my
directory as usual. And here the problem starts. When this library
IronRuby.Libraries.dll is in the directory where my programm is running,
executing the "require 'rubygems'" throws an error. It's the same when I
start ir on the command line and type it in. When I delete this library
ruby code runs without any problem, but the program won't execute
any more. Here's the error message:

    C:/Program Files/IronRuby 1.1/Lib/ironruby/thread.rb:16:in
`load_assembly': Specified type
IronRuby.StandardLibrary.Threading.ThreadingLibraryInitializer is not a
subclass of IronRuby.Builtins.LibraryInitializer (LoadError)
    from C:/Program Files/IronRuby 1.1/Lib/ironruby/thread.rb:16
    from C:/Program Files/IronRuby 1.1/Lib/ruby/1.9.1/rubygems.rb:16:in
    from C:/Program Files/IronRuby 1.1/Lib/ruby/1.9.1/rubygems.rb:16
    from (ir):1:in `require'
    from (ir):1

The versions I use:
IronRuby on .NET 4.0.30319.239
MS Visual Studio 2010

I desperately hope for help as I couldn't any helping post in the
thanks in advance
Orion Edwards (Guest)
on 2012-01-30 00:23
(Received via mailing list)
Not sure if this is your problem, but off the top of my head I'll try

IronRuby needs to know the path to it's standard library directory. This
is stored in the ir.exe.config file that ships along with IronRuby.
When you host IronRuby from inside another application, this config file
isn't present.
Rubygems isn't one of the core libraries (those are implemented in
IronRuby.Libraries.dll), and so when you try and require rubygems, it
goes looking for the standard library, and fails.

Try open ir.exe.config from the IronRuby directory, and copy the parts
which reference file paths over to your own app.exe.config (and remember
to update the paths, etc).

It should look kind of like this (NOTE: this is an old config file and
so it won't be correct for the latest version of ir):

This topic is locked and can not be replied to.