Assistance Needed Running IronRuby.Rack.Example

Could I get some assistance in running rack on IronRuby? I am just
trying out:

http://github.com/jschementi/ironruby/tree/master/Merlin/Main/Hosts/IronRuby.Rack

from RailsConf, not the latest one from the IronRuby tree. Everything
has built successfully and I had to modify Web.config to point to my
MRI 1.8 installation directory but this is as far as I can get. I
have tried both igem install rack and gem install rack but I still
receive this message. Running on IIS7 under Windows Vista 64bit. I
do not have any release versions of IronRuby installed on this
machine. I did not have a IIS_IUSER to assign permissions to but I
did try assigning read/execute permissions to the IIS_IUSRS group with
no change.

Assuming I can get this to work, could I also get some instructions on
how to run Sinatra on top of this?

Error: Gem::LoadError

c:/progra~2/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:826:in
report_activate_error': Could not find RubyGem rack (= 1.0.0) (Gem::LoadError) from c:/progra~2/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:260:in activate’
from c:/progra~2/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:67:in gem' from :0 from C:\src\Merlin\Main\Hosts\IronRuby.Rack\RubyEngine.cs:43:in Execute’
from C:\src\Merlin\Main\Hosts\IronRuby.Rack\RubyEngine.cs:39:in
Execute' from C:\src\Merlin\Main\Hosts\IronRuby.Rack\RubyEngine.cs:31:in Require’
from C:\src\Merlin\Main\Hosts\IronRuby.Rack\Application.cs:49:in
InitRack' from C:\src\Merlin\Main\Hosts\IronRuby.Rack\Application.cs:28:in .ctor’
from
C:\src\Merlin\Main\Hosts\IronRuby.Rack\HttpHandlerFactory.cs:41:in
GetHandler' from System.Web:0:in System.Web.HttpApplication.IExecutionStep.Execute’
from System.Web:0:in ExecuteStep' from System.Web:0:in ResumeSteps’
from System.Web:0:in BeginProcessRequestNotification' from System.Web:0:in ProcessRequestNotificationPrivate’
from System.Web:0:in ProcessRequestNotificationHelper' from System.Web:0:in ProcessRequestNotification’
from System.Web:0:in ProcessRequestNotificationHelper' from System.Web:0:in ProcessRequestNotification’

Search paths

C:/src/Merlin/Main/Hosts/IronRuby.Rack/IronRuby.Rack.Example
C:/src/Merlin/Main/Languages/Ruby/Libs
c:/progra~2/ruby/lib/ruby/site_ruby/1.8
c:/progra~2/ruby/lib/ruby/site_ruby
c:/progra~2/ruby/lib/ruby/1.8
.

nRuby.Rack

from RailsConf, not the latest one from the IronRuby tree.

I’m pretty sure both versions are identical, so you can pick either one.

Everything has
built successfully and I had to modify Web.config to point to my MRI 1.8
installation directory but this is as far as I can get. I have tried both igem
install rack and gem install rack but I still receive this message. Running on
IIS7 under Windows Vista 64bit. I do not have any release versions of
IronRuby installed on this machine. I did not have a IIS_IUSER to assign
permissions to but I did try assigning read/execute permissions to the
IIS_IUSRS group with no change.

Woops, I got the IIS_IUSRS name wrong … I’ll change the README to
reflect that.

Assuming I can get this to work, could I also get some instructions on how to
run Sinatra on top of this?

It worked the first time on my machine, so let’s figure out what’s
different …

Error: Gem::LoadError

c:/progra~2/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:826:in
`report_activate_error’: Could not find RubyGem rack (= 1.0.0)
(Gem::LoadError)

So, it finds RubyGems (which is good, that means the paths are set up
properly) but it doesn’t find the Rack gem. Sounds like it wouldn’t be
able to find any gems … if you executed this from the immediate window
it would probably throw an error too:

RubyEngine.Require(“sinatra”)

However, the issue you see is completely my fault. Take a look at line
43 of Application.cs:
http://github.com/jschementi/ironruby/blob/fc84e8dc9d563b7dde9cd7c2506488f190f98c3b/Merlin/Main/Hosts/IronRuby.Rack/Application.cs#L43

// HACK Load gems from default MRI installation. This shouldn't be 

needed.
Environment.SetEnvironmentVariable(“GEM_PATH”,
@“C:\ruby\lib\ruby\gems\1.8”);

I’m being pretty evil here and setting GEM_PATH over your head. This
line should be set to “c:\progra~2\ruby\lib\ruby\gems\1.8” for you if
you want to use MRI’s gems, or the path to rubygems that IronRuby sets
up (do a "echo %GEM_PATH% from Dev.bat to get that value). A simple
recompile should make things work again.

I’ll pull GEM_PATH out into a setting in web.config so this doesn’t
suck. =P Thanks for reporting it!

~js

I just made some updates so GEM_PATH can be set from web.config, so if
you use those bits just make sure GemPath is set correctly in web.config
and all should work well.
http://github.com/jschementi/ironruby/commit/4dd9655f4a48326fb1270a2eb2cf5d1f96d7c3b0

On Tue, Jun 23, 2009 at 4:40 PM, Jimmy
Schementi[email protected] wrote:

// HACK Load gems from default MRI installation. This shouldn’t be needed.
Environment.SetEnvironmentVariable(“GEM_PATH”, @“C:\ruby\lib\ruby\gems\1.8”);

I’m being pretty evil here and setting GEM_PATH over your head. This line should be set to “c:\progra~2\ruby\lib\ruby\gems\1.8” for you if you want to use MRI’s gems, or the path to rubygems that IronRuby sets up (do a "echo %GEM_PATH% from Dev.bat to get that value). A simple recompile should make things work again.

Yep, that did it. I just updated the path to reflect my MRI install
and it is working now. I am sure this has been covered on the list and
I am just forgetting, but igem is just a way to manage a separate set
of installed gems, correct? There is nothing special about the gems it
retrieves vs. the ones from an MRI install?

Now, on to what I really wanted to do, run Sinatra. I tried a simple
Hello World but I get a YSOD about an undefined method ‘call’. I
modified config.ru to require my new .rb file and tried both:

require ‘rubygems’
require ‘sinatra’

class App
get ‘/’ do
‘Hello world!’
end
end

and after commenting out App.new in config.ru:

require ‘rubygems’
require ‘sinatra’

get ‘/’ do
‘Hello world!’
end

but they both give a similar stack trace:

Server Error in ‘/IronRuby.Rack.Example’ Application.

undefined method `call’ for #App:0x0000536

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: undefined method
`call’ for #App:0x0000536

Source Error:

Line 458: public static object MethodMissing(RubyContext/!/
context, object/!/ self, SymbolId symbol, [NotNull]params
object[]/!/ args) {
Line 459: string name = SymbolTable.IdToString(symbol);
Line 460: throw RubyExceptions.CreateMethodMissing(context,
self, name);
Line 461: }
Line 462:

Source File:
C:\src\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\KernelOps.cs
Line: 460

Stack Trace:

[MissingMethodException: undefined method call' for #<App:0x0000536>] IronRuby.Builtins.KernelOps.MethodMissing(RubyContext context, Object self, SymbolId symbol, Object[] args) in C:\src\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\KernelOps.cs:460 CallSite.Target(Closure , CallSite , Object , Object ) +317 System.Dynamic.UpdateDelegates.UpdateAndExecute2(CallSite site, T0 arg0, T1 arg1) in C:\src\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs:384 Microsoft.Scripting.Runtime.DynamicOperations.InvokeMember(Object obj, String memberName, Boolean ignoreCase, Object[] parameters) in C:\src\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\DynamicOperations.cs:118 Microsoft.Scripting.Runtime.DynamicOperations.InvokeMember(Object obj, String memberName, Object[] parameters) in C:\src\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\DynamicOperations.cs:101 Microsoft.Scripting.Hosting.ObjectOperations.InvokeMember(Object obj, String memberName, Object[] parameters) in C:\src\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ObjectOperations.cs:85 IronRuby.Rack.RubyEngine.ExecuteMethod(Object instance, String methodName, Object[] args) in C:\src\Merlin\Main\Hosts\IronRuby.Rack\RubyEngine.cs:48 IronRuby.Rack.Application.Call(IDictionary2 env) in
C:\src\Merlin\Main\Hosts\IronRuby.Rack\Application.cs:38
IronRuby.Rack.Handler.IIS.Handle(Request request, Response
response) in C:\src\Merlin\Main\Hosts\IronRuby.Rack\IIS.cs:238
IronRuby.Rack.HttpHandler.ProcessRequest(HttpContext context) in
C:\src\Merlin\Main\Hosts\IronRuby.Rack\HttpHandler.cs:46
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +171

Version Information: Microsoft .NET Framework Version:2.0.50727.3074;
ASP.NET Version:2.0.50727.3074

The only difference is whether the the undefined method is for App or
nil:NilClass.

I’ll look into it, but last I checked all the examples worked fine.


From: [email protected]
[[email protected]] on behalf of Nathan Stults
[[email protected]]
Sent: Thursday, October 08, 2009 4:54 PM
To: [email protected]
Subject: Re: [Ironruby-core] Assistance Needed Running
IronRuby.Rack.Example

Exception Details: System.MissingMethodException: undefined method
`call’ for #App:0x0000536

Source Error:

Ted - did you ever resolve this? I’m seeing the same thing. It’s as if
Sinatra:Application (the dynamic object returned by Rackup) doesn’t
respond to ‘call’. I can’t keep the debugger running long enough to
explore the dynamic target long enough to confirm or reject though.

Posted via http://www.ruby-forum.com/.


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

Maybe it has something to do with the version of Sinatra gem installed.
Also, the actual missing method error is:

undefined method `empty?’ for nil:NilClas

So, this may be different than what Ted was getting.

but they both give a similar stack trace:

Server Error in ‘/IronRuby.Rack.Example’ Application.

undefined method `call’ for #App:0x0000536

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: undefined method
`call’ for #App:0x0000536

Source Error:

Ted - did you ever resolve this? I’m seeing the same thing. It’s as if
Sinatra:Application (the dynamic object returned by Rackup) doesn’t
respond to ‘call’. I can’t keep the debugger running long enough to
explore the dynamic target long enough to confirm or reject though.

I found the problem, and posted an issue on your GitHub repository with
a description / solution. Very simple fix, tremendously convoluted
debugging experience :slight_smile:

Got it. I’ll make that change, and it’s about time some tests were added
as well, so I’ll make a regression test for it. Thanks for tracking this
down!

I think I may be using an upatched version of Sinatra - please don’t
bother looking into this issue, I’ll figure it out and if it is a bug
I’ll report it, otherwise it’s on my end.