[Ironruby-core] IronRuby version of existing gems

Shri Borde Shri.Borde at microsoft.com
Wed Mar 10 00:00:34 EST 2010


Glad that we were able to figure out the issue! The fix did make it into RC3 as well!

It would be great if you could coordinate getting the fix into the RubyGem sources!

From: Will Green [mailto:will at hotgazpacho.org]
Sent: Tuesday, March 09, 2010 6:49 PM
To: Shri Borde
Subject: Re: [Ironruby-core] IronRuby version of existing gems

Excellent! I just pulled the changes and confirm that I can now install directly from RubyGems.org.

Would you like me to coordinate getting the change to RubyGems into the source? I know at least two of the comitters listed on the  RubyForge project page: http://rubyforge.org/scm/?group_id=126

Let me know!

--
Will Green
http://hotgazpacho.org/

On Tue, Mar 9, 2010 at 1:30 PM, Shri Borde <Shri.Borde at microsoft.com<mailto:Shri.Borde at microsoft.com>> wrote:
The =~ method needs to be fixed, but fixing that does not help since it gets called with an argument of “universal-unknown”.

I did find a workaround. If I add the following in Gem::Specification._load around line 308 in Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\site_ruby\1.8\rubygems\specification.rb, I am able to install iron-term-ansicolor-0.0.4-universal-.net.

    if array[8] == "universal-.net"
      array[16] = Gem::Platform.new(["universal", ".net"]) if array[16] == Gem::Platform.new(["universal", "unknown"])
    end

Will try to get it into RTM (not sure if it will make it into RC3)

From: Will Green [mailto:will at hotgazpacho.org<mailto:will at hotgazpacho.org>]
Sent: Tuesday, March 09, 2010 4:38 AM

To: Shri Borde
Subject: Re: [Ironruby-core] IronRuby version of existing gems

The thing is, this works with RC2:

igem install iron-term-ansicolor --platform universal-.net

C:\ironruby\bin>igem install iron-term-ansicolor --platform universal-.net
Successfully installed iron-term-ansicolor-0.0.4-universal-unknown
1 gem installed
Installing ri documentation for iron-term-ansicolor-0.0.4-universal-unknown...
Installing RDoc documentation for iron-term-ansicolor-0.0.4-universal-unknown...

Sure, it recognizes it as universal-unknown, but it still works.

It doesn't work at all with HEAD. I think you missed a spot with the platform detection in Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/site_ruby/1.8/rubygems/platform.rb

Specifically, the =~ method, which I think gets called because in the gem spec, the platform is serialized as a string. Just a hunch, but it couldn't hurt to investigate.

What do you think?

--
Will Green
http://hotgazpacho.org/
On Tue, Mar 9, 2010 at 2:27 AM, Shri Borde <Shri.Borde at microsoft.com<mailto:Shri.Borde at microsoft.com>> wrote:
I can see the new gem with “gem query” but “gem install” will not install it.

d:\ >gem query -d -r -n iron-term-ansicolor

*** REMOTE GEMS ***

iron-term-ansicolor (0.0.4)
    Platform: universal-.net
    Authors: Will Green, David Blackmon, Ivan Porto Carrero, Danny
    Coates
    Homepage: http://github.com/hotgazpacho/iron-term-ansicolor

    iron-term-ansicolor brings color output to IronRuby on Windows

d:\ >gem install iron-term-ansicolor --no-rdoc --no-ri
ERROR:  could not find gem iron-term-ansicolor locally or in a repository

d:\ >ir.exe -S gem install iron-term-ansicolor --no-rdoc --no-ri
ERROR:  could not find gem iron-term-ansicolor locally or in a repository

It does seem to be the issue I mentioned about the remote gem server, because adding logging in Gem::Specification._load shows that @platform and @new_platform are “universal-unknown” when trying to install from a remote server. When you install locally, marshalling is not an issue. However, when you install from a remote server, the remote server is going to have to send information to the client about matching gems, and this information must be in marshaled data format.

What this means is that setting platform to “universal-.net” will not work until a patch is made to RubyGems in platform.rb (like has already been done for JRuby). The workaround will be to set the platform to “ruby” for now, or to create two gems with platforms set to “universal-.net2.0” and “universal-.net4.0”. Do you want to push updates with platforms set to “universal-.net2.0” and “universal-.net4.0”?

Thanks for helping to figure out how all this works or should work!!

From: Will Green [mailto:will at hotgazpacho.org<mailto:will at hotgazpacho.org>]
Sent: Monday, March 08, 2010 8:17 PM

To: Shri Borde
Subject: Re: [Ironruby-core] IronRuby version of existing gems

I've made the change you suggested. Here's the gemspec that IronRuby sees and that MRI sees: (igem spec iron-term-ansicolor-0.0.4-universal-.net.gem and gem spec iron-term-ansicolor-0.0.4-universal-.net.gem)

http://gist.github.com/326161

Both see platform: universal-.net

Which is great, because I think that means the gemspec is just YAML, so marshaling is really not an issue.

I am able to successfully install locally, too. So, I'm going to bump the patch level, commit my changes, push to github, and publish the gem.

Thanks for your help!

--
Will Green
http://hotgazpacho.org/
On Mon, Mar 8, 2010 at 1:17 PM, Shri Borde <Shri.Borde at microsoft.com<mailto:Shri.Borde at microsoft.com>> wrote:
When I search for “unknown” in the Ruby Gem sources, the only relevant occurrence is in Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\site_ruby\1.8\rubygems\package.rb, which I did fix.

Something just occurred to me. Creating the gem just zips up all the files together, and does not seem to marshal any data-structures, whereas I am seeing that the marshaled representation of Gem::Specification contains @original_platform=@new_platform=”universal-unknown”. So I wonder if the gem server on rubyforge marshals the contents of the gem. It might need to do this so that it can cache the results efficiently. Assuming it does do this, the gem server will be running MRI and will not have the fix to rubygem\package.rb, and so will generate the corrupt value of ”universal-unknown”.

One possible workaround is to do this:
s.platform = Gem::Platform.new(["universal", ".net"])
By using an array of size 2 as the argument, MRI will be able to parse the platform into the CPU and OS components, even without my fix to rubygems\package.rb. Could you please create a gem as such, make sure it works as expected locally, and then push it? I did apply this fix to Rakefile, and “ir.exe –S rake package” was able to create the gem.

From: Will Green [mailto:will at hotgazpacho.org<mailto:will at hotgazpacho.org>]
Sent: Monday, March 08, 2010 3:44 AM
To: Shri Borde

Subject: Re: [Ironruby-core] IronRuby version of existing gems

Yes, I can install the universal-.net<http://universal-.net> gem locally, when I create it from my git repo.

I can certainly recreate and repush that gem. Maybe I can do a version bump to 0.0.4 and push only the universal-.net<http://universal-.net> gem for now.

I'd also look at the change to Ruby Gems again. I seem to recall there being more than one place in that file where it did platform name mangling. But I may be mistaken.

Thanks for looking into this, and keep up the good work!

--
Will Green
http://hotgazpacho.org/



On Mar 8, 2010, at 2:42 AM, Shri Borde <Shri.Borde at microsoft.com<mailto:Shri.Borde at microsoft.com>> wrote:
I did “ir.exe –S rake package” from your GIT repo, followed by “ir.exe –S gem install pkg\iron-term-ansicolor-0.0.3-universal-.net.gem”, and it seems to do the right thing. Does that work for you?

This is the repro I am using to drill into the issue. With no changes to rbconfig.rb, I added the highlighted line to Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ruby\site_ruby\1.8\rubygems\specification.rb at line 328 in the _load function:

    spec.instance_variable_set :@new_platform,              array[16]
    spec.instance_variable_set :@platform,                  array[16].to_s
    spec.instance_variable_set :@license,                   array[17]
    spec.instance_variable_set :@loaded,                    false
    puts "ori=#{spec.instance_variable_get(:@original_platform)} new=#{spec.instance_variable_get(:@new_platform)} p=#{spec.instance_variable_get(:@platform)}"
    spec

I ran the command shown below, and the platform is printed incorrectly. This data comes from the serialized string representation in the gem, and so it seems like the gem is corrupt

ir.exe -S gem install iron-term-ansicolor --platformuniversal-.net-4.0 --no-rdoc --no-ri
ori=universal-.net new=universal-unknown p=universal-unknown
ori=ruby new=ruby p=ruby
ori=ruby new=ruby p=ruby
Successfully installed iron-term-ansicolor-0.0.3


From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Shri Borde
Sent: Sunday, March 07, 2010 6:53 PM
To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Subject: Re: [Ironruby-core] IronRuby version of existing gems

Will, could you recreate the universal-.net<http://universal-.net> gem again and push it? I think it might have been created incorrectly. The persisted Gem::Specification has @new_platform and @original_platform set to “universal-unknown” which might happen if you create it with MRI as I had mentioned below…

From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Shri Borde
Sent: Sunday, March 07, 2010 2:27 PM
To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Subject: Re: [Ironruby-core] IronRuby version of existing gems

My guess is that RubyGems tries to look for an exact platform match first. If there is no exact match, it somehow prefers “ruby” over other platforms.

Btw, you could just change clr_version in Merlin\Main\Languages\Ruby\Libs\rbconfig.rb to “4.0” to simulate running on .NET 4. After doing this and using the “—platform universal-.net<http://universal-.net>” option, iron-term-ansicolor-0.0.3-universal-.net<http://iron-term-ansicolor-0.0.3-universal-.net>-2.0 was installed which was surprising to me as I would have expected it to install iron-term-ansicolor-0.0.3-universal-.net<http://iron-term-ansicolor-0.0.3-universal-.net>. When I used the “—platform universal-.net-4.0” option, iron-term-ansicolor-0.0.3 was installed which was also surprising. So there does not seem to be any way to install iron-term-ansicolor-0.0.3-universal-.net<http://iron-term-ansicolor-0.0.3-universal-.net>.

From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Will Green
Sent: Sunday, March 07, 2010 6:33 AM
To: ironruby-core
Subject: Re: [Ironruby-core] IronRuby version of existing gems

Thanks, Daniele!

I've got three version of iron-term-ansicolor out there on RubyGems.org<http://RubyGems.org>:


  *   iron-term-ansicolor-0.0.3                     (gemspec.platform="ruby")
  *   iron-term-ansicolor-0.0.3-universal-.net<http://iron-term-ansicolor-0.0.3-universal-.net>      (gemspec.platform="universal-.net<http://universal-.net>")
  *   iron-term-ansicolor-0.0.3-universal-.net-2.0  (gemspec.platform="universal-.net-2.0")

It looks like the .Net 4 runtime selected the non-platform specific gem, while the .Net 2 runtime selected the "universal-.net-2.0" gem.

--
Will Green
http://hotgazpacho.org/
On Sun, Mar 7, 2010 at 4:01 AM, Daniele Alessandri <suppakilla at gmail.com<mailto:suppakilla at gmail.com>> wrote:
On Sun, Mar 7, 2010 at 08:07, Will Green <will at hotgazpacho.org<mailto:will at hotgazpacho.org>> wrote:

> I would appreciate if someone running the latest from git would try
> ir -S gem install iron-term-ansicolor
> on both the .Net 2 and the .Net 4 runtimes, and let me know which gem gets
> installed.
C:\Users\nrk\Repositories\ironruby\Merlin\Main\bin\Debug>ir --version
IronRuby 0.9.4.0 on .NET 2.0.50727.4200

C:\Users\nrk\Repositories\ironruby\Merlin\Main\bin\Debug>ir -S gem
install iron-term-ansicolor --no-rdoc --no-ri
Successfully installed iron-term-ansicolor-0.0.3-universal-.net-2.0
1 gem installed
C:\Users\nrk\Repositories\ironruby\Merlin\Main\bin\Debug>ir --version
IronRuby 0.9.4.0 on .NET 4.0.30128.1

C:\Users\nrk\Repositories\ironruby\Merlin\Main\bin\Debug>ir -S gem
install iron-term-ansicolor --no-rdoc --no-ri
Successfully installed iron-term-ansicolor-0.0.3
1 gem installed

--
Daniele Alessandri
http://www.clorophilla.net/
http://twitter.com/JoL1hAHN
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100310/17b01c83/attachment-0001.html>


More information about the Ironruby-core mailing list