RubyGems

From $1

Table of contents
    1. 1.1. Usage
      1. 1.1.1. Native gems
      2. 1.1.2. IronRuby-specific gems
  1. 2. Known issues

RubyGems 1.2 (will be updated to 1.3.1) is included with IronRuby. The "bin" folder also includes igem.bat which can be used to manage gems with IronRuby, similar to the gem.bat used by MRI.

Usage

There are two ways to use gems:

  • Do not share gems with MRI - By default, RubyGems looks in different locations for each Ruby implementation. For IronRuby, it would look in c:\ironruby\lib\ironruby\gems\1.8 assuming ir.exe exists in c:\ironruby\bin. In this case, you will need to install all gems you want to use with IronRuby using igem.bat (c:\ironruby\bin\igem.bat), even if the gem was previously installed for MRI using gem.bat.
  • Share gems with MRI - Set the GEM_PATH environment variable in your user profile to point to your <mri>\lib\ruby\gems\1.8 directory, e.g. c:\ruby\lib\ruby\gems\1.8. This allows sharing of gems with MRI. IronRuby also includes igem.bat which runs gems with IronRuby. This can be used to install IronRuby-specific gems.
    • Note that the GEM_HOME environment variables controls where new gems will be installed by running igem.bat. Unless you set this to match GEM_PATH, note that gems installed by "igem.bat" may not be usable from IronRuby [need to check if this is true or not]. And if you set GEM_PATH to include the location of IronRuby gems, MRI will be able to find them as well.

Many gems create wrapper batch files for convinience. For example, the Rails gem adds rails.bat to the bin folder, and the Cucumber gem adds cucumber.bat to the bin folder. However, the names of the batch files can conflict with the batch files used by MRI. The IronRuby releases include a few such batch files with "i" prepended to the name (eg. igem.bat), but it cannot include them all. Also, note that you can use the GEM_BIN folder to control where "gem install" will install such batch files in case you do not like the default location of the "bin" folder.

Native gems

Native gems are gems with Ruby native extensions containing native code. The platform  attribute will be Gem::Platform::Win32, and gem filename will be something like foo-1.2.3-win32.gem. Native extensions are not supported by IronRuby. Currently, there is no known way of avoiding native gems. When you install gems, you will have to manually exclude gems with win32 in the name. If a native gem is installed by MRI and you are sharing gems with MRI, requiring the gem can fail even if you have a version with platform=ruby installed [Need to check exactly what happens in this case, and which platform gets precedence].

IronRuby-specific gems

Gems could specifically target IronRuby. They may contain Ruby code which uses .NET APIs, or they may even include compiled .NET assemblies. In such cases, the Gem specification should set platform to "universal-dotnet" (or "universal-dotnet4.0" to run only on .NET 4), and build the gem using IronRuby ("ir.exe -S igem build").

Note that if you build the gem with MRI using "gem build", MRI will not be able to recognize the platform string, and will create a gem file named something like foo-universal-unknown.gem (instead of the expected foo-universal-dotnet.gem"). To avoid this, build the gem using IronRuby as mentioned above.

[Need to check if this works seamlessly, if the assembly loads fine, if the gem can consist of multiple assemblies or if there will be LoadFrom problems, etc]

Known issues

  • Native extensions are not supported.
  • Signed gems cannot be used since IronRuby does not support OpenSSL yet.
Tags:
 
Images (0)
 
Comments (1)
Viewing 1 of 1 comments: view all
Viewing 1 of 1 comments: view all
You must login to post a comment.

 
SourceForge.net