[Ironruby-core] Trying to run _why's Camping framework on IronRack / IIS

Jimmy Schementi Jimmy.Schementi at microsoft.com
Mon Aug 31 01:47:37 EDT 2009

Ah, gotcha. Thanks for the explanation Tomas. I'll make that change.

Sent from my phone

On Aug 30, 2009, at 10:24 PM, "Tomas Matousek" <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote:

The constant is not set when hosting IR and using Engine.Execute() or ScriptScope.Execute().
It is only set by ScriptSource.ExecuteProgram(). The reason is that each call to the former methods creates a new top-level binding and therefore we don’t know which one should be the one that is stored in TOPLEVEL_BINDING. The latter is meant to be used to execute the main top-level code (i.e. the “program”) and it sets the TOPLEVEL_BINDING up. It also handles SystemExit exception so that “exit” works according to Ruby’s semantics.

IronRack should probably use ExecuteProgram to execute the main request processing script.


From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Philippe Monnet
Sent: Sunday, August 30, 2009 1:05 PM
To: <mailto:ironruby-core at rubyforge.org> ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Subject: Re: [Ironruby-core] Trying to run _why's Camping framework on IronRack / IIS

Today I dug deeper in the issue by breaking down the goes method of Camping in small chunks and evaluating them both in IR and MRI. I found that one thing expected by Camping was the global constant TOPLEVEL_BINDING.
Apparently the constant was not defined in IR. A Google search found it in:
And when I explicitly required it, the constant appeared and Camping worked immediately on IronRack.
Could someone explain what the constant is for and why it is located in hacks.rb?
Is it ok to I be using hacks.rb?


PS - I am pretty excited to run Camping now! I just had to make a couple changes on top of IronRack to make it work.

Philippe Monnet wrote:
I have been leveraging IronRack to try to get a sample Camping application up and running.
I seem to be able to require the camping library fine but then as try to hit the famous "Camping.goes :Demo" line, IronRuby return an error stating that the constant #<Class:Camping> is not initialized.
So I tried to do the same test using the IR command line executable, but ran into the same issue (note that the same test works fine in IRB). What is strange is that the camping framework is loaded and if I query the constants in the Camping module I get back what I would expect. Is this a module loading issue? How can I troubleshoot this further?

Here is the IR's transcript:

    IronRuby on .NET 2.0.50727.3082
    Copyright (c) Microsoft Corporation. All rights reserved.

    >>> require 'rubygems'
    => true

    >>> gem 'rack'
    => true

    >>> require 'rack'
    => true

    >>> gem 'camping'
    => true

    >>> require 'camping'
    => ["Camping"]

    >>> require 'demo'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant #<Class:Camping>::TOPLEVEL_BINDING (NameError)
            from C:/Ruby/lib/ruby/gems/1.8/gems/camping-1.5.180/lib/camping.rb:39:in `goes'
            from ./demo.rb:3
            from :0
            from :0:in `require'
            from custom_require.rb:30:in `require'
            from dependencies.rb:156:in `require'
            from dependencies.rb:490:in `new_constants_in'
            from dependencies.rb:154:in `require'

And the basic 'demo.rb' looks like the following:

require 'camping'

Camping.goes :Demo

module Demo
  def Demo.create

module Demo::Models

module Demo::Controllers
  class Index < R '/'
    def get
      render :index

module Demo::Views
  def layout
    html do
      body do
        self << yield

  def index
    h1 "#{@input.name}, Welcome to my IronCamping demo!"<mailto:#%7B at input.name%7D,WelcometomyIronCampingdemo%21>



Ironruby-core mailing list

<mailto:Ironruby-core at rubyforge.org>Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>


Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090831/4191a673/attachment.html>

More information about the Ironruby-core mailing list