R105 broke assembly loading

Hi

I just updated to r105 and now I can’t require assemblies anymore.

require ‘bin/System.Net.dll’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
Require': Invalid character '?' in expression (Synta xError) from :0:inInitialize##1

Do I submit a bug for that?

Cheers
Ivan

This is a feature and not a bug :slight_smile:

You’ll need to specify the fully qualified assembly name:

require “System.Net, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL”

However, you can also just put a file called system.net.rb in your
search path and have it do the scary require which gets you back to

require ‘system.net

Thanks,
-John

One more thing, r105 adds support for the -I command line switch, so you
can now:

ir -I path-to-your-includes-directory yourapp.rb

Thanks,
-John

maybe system.net was a bad example.

I also have a compiled dll that contains my objects… when I run my
specs with r104 things work
when I do it with r105 they don’t anymore. They always fail on those
require lines.

and you’re saying that now I don’t have to go through a
assemblies.each{|assembly| require assembly} anymore but can just do
ir -l bin lib/main.rb to get my app going ?


in the past I just had to do require path_to_my_own_assembly
It seems that that has changed now? At this moment it doesn’t seem to
recognize a .dll as an assembly but rather wants to execute is as a
ruby source file. Where before the LoadModule method would call
GetFileKind at some point and correctly identify .dll as an assembly.


I did some more investigating and it seems like File.dirname(FILE)
doesn’t report the correct directory in the console

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby
    » ir
    IronRuby 1.0.0.0 on .NET 2.0.50727.1434
    Copyright (c) Microsoft Corporation. All rights reserved.

Note that local variables do not work today in the console.
As a workaround, use globals instead (eg $x = 42 instead of x = 42).

File.dirname(FILE)
=> “C:\projects\lumpr\src\Sylvester.DesktopEdition”

I thought it would to return => “C:\projects\lumpr\src
\Sylvester.DesktopyEdition\Sylvester.IronRuby”

Thanks
Ivan

Ok I’m all for features but how do I now require my own homebaked dll
because registering them in the GAC isn’t the way to go IMHO :slight_smile:

I’ve tried a bunch of things to get to my dll but it boils down to
that it doesn’t know how to load it. When I copy my assembly into the
ironruby build folder it does work. That just doesn’t seem right to
me. If there is a new an elegant way to load arbitrary assemblies then
I’d love to know. In meantime I can hack my source to add assembly
loading from a path as well

Below the output from my various tries to get my assembly loaded
without putting it in the ironruby binaries folder

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby
    » ir -I C:\projects\lumpr\src\Sylvester.DesktopEdition
    \Sylvester.IronRuby\bin\Sylvester.Contracts.dll

include Twitter::Model
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\ModuleOps.cs:642:in
ConstantMissing': uninitialized constant Object:: Twitter (NameError) from :0:inInitialize##1

exit

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby
    » ir -I C:\projects\lumpr\src\Sylvester.DesktopEdition
    \Sylvester.IronRuby\bin

require ‘Sylvester.Contracts, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
Require': no such file to load -- Sylvester.Contract s, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (LoadError) from :0:inInitialize##1

exit

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby
    » ir

Dir.chdir(‘C:\projects\lumpr\src\Sylvester.DesktopEdition
\Sylvester.IronRuby\bin’)
=> 0

require ‘Sylvester.Contracts, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
Require': no such file to load -- Sylvester.Contract s, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (LoadError) from :0:inInitialize##7

exit

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby
    » ir -I C:\projects\lumpr\src\Sylvester.DesktopEdition
    \Sylvester.IronRuby\bin

Dir.chdir(‘C:\projects\lumpr\src\Sylvester.DesktopEdition
\Sylvester.IronRuby\bin’)
=> 0

require ‘Sylvester.Contracts, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
Require': no such file to load -- Sylvester.Contract s, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (LoadError) from :0:inInitialize##8

Thanks
Ivan

That also isn’t working for me.
If I use /paths:full path here or -I “full path here” it still doesn’t
let me require that assembly .

I’m having trouble with strong names in the latest version.

Is IronRuby.dll meant to be strongly named?

The Microsoft.Scripting.Hosting.ScriptRuntimeSetup constructor has a
hard coded dependence to:

IronRuby, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35

But building IronRuby.dll using IronRuby.csproj doesn’t seem to produce
a strongly named assembly.

I also note that IronRuby.csproj doesn’t set SIGNED but the other
projects do.

Cheers, Wayne.

I haven’t tried revision 105 to know if it still works but I’ve been
using
the /paths command line option to tell IronRuby where my assemblies are.

ir.exe paths/:C:\paths\to\my\dlls my_ruby_script.rb

Cheers,
Steve

On Tue, May 13, 2008 at 9:17 PM, Ivan Porto C.
[email protected]

My understanding is that when IronRuby is officially released it /will/
be
signed, going through and removing the “SIGNED” variable from the other
projects should allow it to build correctly. The hard coded dependence
below is in an #if.

It’s always been like this, in fact I had to reference removing the
SIGNED
in my quick start which was back in rev75 (or thereabouts).

Hi,

I submitted a patch that restores that original behavior.

Cheers
Ivan

On Wed, May 14, 2008 at 5:11 PM, Tomas M. <

I see. The problem is that an application that is written in a scripting
language is not treated the same as a compiled .exe file in CLR’s
assembly loading mechanism. Executable file defines a directory from
whose subdirectories could private assemblies be loaded. Since we have
no .exe file for Ruby apps CLR loader doesn’t consider the root of the
app during the search for an assembly.
I’ll add support for loading from .dlls back. Framework assemblies
should still be loaded either using Kernel#require().

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 13, 2008 6:50 PM
To: [email protected]
Subject: Re: [Ironruby-core] r105 broke assembly loading

That also isn’t working for me.
If I use /paths:full path here or -I “full path here” it still doesn’t
let me require that assembly .

On 14/05/2008, at 1:27 PM, Steve E. wrote:

I haven’t tried revision 105 to know if it still works but I’ve been
using the /paths command line option to tell IronRuby where my
assemblies are.

ir.exe paths/:C:\paths\to\my\dlls my_ruby_script.rb

Cheers,
Steve
On Tue, May 13, 2008 at 9:17 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:
Ok I’m all for features but how do I now require my own homebaked dll
because registering them in the GAC isn’t the way to go IMHO :slight_smile:

I’ve tried a bunch of things to get to my dll but it boils down to that
it doesn’t know how to load it. When I copy my assembly into the
ironruby build folder it does work. That just doesn’t seem right to me.
If there is a new an elegant way to load arbitrary assemblies then I’d
love to know. In meantime I can hack my source to add assembly loading
from a path as well

Below the output from my various tries to get my assembly loaded without
putting it in the ironruby binaries folder

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby

ir -I C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby\bin\Sylvester.Contracts.dll

include Twitter::Model
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\ModuleOps.cs:642:in
`ConstantMissing’: uninitialized constant Object::
Twitter (NameError)

   from :0:in `Initialize##1'

exit

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby

ir -I C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby\bin

require ‘Sylvester.Contracts, Version=1.0.0.0http://1.0.0.0, Culture=neutral, PublicKeyToken=null’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
`Require’: no such file to load – Sylvester.Contract
s, Version=1.0.0.0http://1.0.0.0, Culture=neutral, PublicKeyToken=null
(LoadError)

   from :0:in `Initialize##1'

exit

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby

ir

Dir.chdir(‘C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby\bin’)
=> 0
require ‘Sylvester.Contracts, Version=1.0.0.0http://1.0.0.0, Culture=neutral, PublicKeyToken=null’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
Require': no such file to load -- Sylvester.Contract s, Version=1.0.0.0<http://1.0.0.0>, Culture=neutral, PublicKeyToken=null (LoadError) from :0:in Initialize##7
exit

  • C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby

ir -I C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby\bin

Dir.chdir(‘C:\projects\lumpr\src\Sylvester.DesktopEdition\Sylvester.IronRuby\bin’)
=> 0
require ‘Sylvester.Contracts, Version=1.0.0.0http://1.0.0.0, Culture=neutral, PublicKeyToken=null’
c:\tools\IronRuby\src\IronRuby.Libraries\Builtins\Kernel.cs:272:in
Require': no such file to load -- Sylvester.Contract s, Version=1.0.0.0<http://1.0.0.0>, Culture=neutral, PublicKeyToken=null (LoadError) from :0:in Initialize##8

Thanks
Ivan

On 14/05/2008, at 10:42 AM, John L. (IRONRUBY) wrote:
One more thing, r105 adds support for the -I command line switch, so you
can now:

ir -I path-to-your-includes-directory yourapp.rb

Thanks,
-John