RubyGems 1.1.0 on Apple Ruby
Eric Hodel | Sun, 30 Mar 2008 03:04:14 GMT
There is a bug on updating RubyGems to 1.1.0 on Apple’s Ruby. The workaround is to run:
sudo gem install rubygems-update sudo update_rubygems
RubyGems 1.1.0
Eric Hodel | Sat, 29 Mar 2008 08:41:00 GMT
Announce: RubyGems Release 1.1.0
Release 1.1.0 adds some new features and fixes some bugs.
New features:
- RubyGems now uses persistent connections on index updates. Index updates are much faster now.
- RubyGems only updates from a latest index by default, cutting candidate
gems for updates to roughly 1/4 (at present). Index updates are even faster
still.
- gem list -r may only show the latest version of a gem, add --all to see all gems.
- gem spec now extracts specifications from .gem files.
- gem query --installed to aid automation of checking for gems.
Bugs Fixed:
- RubyGems works with both Config and RbConfig now.
- Executables are now cleaned upon uninstall.
- You can now uninstall from a particular directory.
- Updating from non-default sources fixed.
- Executable stubs now use ruby install name in shebang.
- gem unpack checks every directory in Gem.path now.
- gem install now exits with non-zero exit code when appropriate.
- gem update only updates gems that need updates.
- gem update doesn't force remote-only updates.
- gem update handles dependencies properly when updating.
- Gems are now loaded in Gem.path order.
- Gem stub scripts on windows now work outside Gem.bindir.
- gem sources -r now works without network access.
Other Changes Include:
- RubyGems now requires Ruby > 1.8.3.
- Release notes are now printed upon installation.
- gem env path now prints a usable path.
- gem install reverts to local-only installation upon network error.
- Tar handling code refactoring and cleanup.
- Gem::DependencyInstaller's API has changed.
For a full list of changes to RubyGems, see the ChangeLog file.
How can I get RubyGems?
NOTE: If you have installed RubyGems using a package system you may want to install a new RubyGems through the same packaging system.
If you have a recent version of RubyGems (0.8.5 or later), then all you need to do is:
$ gem update --system (you might need to be admin/root)
(Note: You may have to run the command twice if you have any previosly installed rubygems-update gems).
If you have an older version of RubyGems installed, then you can still do it in two steps:
$ gem install rubygems-update (again, might need to be admin/root) $ update_rubygems (... here too)
If you don't have any gems install, there is still the pre-gem approach to getting software … doing it manually:
- DOWNLOAD FROM: rubyforge.org/frs/?group_id=126
- UNPACK INTO A DIRECTORY AND CD THERE
- INSTALL WITH: ruby setup.rb (you may need admin/root privilege)
To File Bugs
The RubyGems bug tracker can be found on RubyForge at: rubyforge.org/tracker/?func=add&group_id=126&atid=575
When filing a bug, gem env output will be helpful in diagnosing the issue.
If you find a bug where RubyGems crashes, please provide debug output. You can do that with gem --debug the_command.
Thanks
Keep those gems coming!
— Jim & Chad & Eric (for the RubyGems team)
Safari 3.1
Eric Hodel | Tue, 18 Mar 2008 21:08:26 GMT
Safari 3.1 fixed a bug I found with urlbar-less tab reloading and removed the Debug menu, with the important bits split off into the Developer menu. To get the Debug menu from Safari 3.x and earlier, set the IncludeInternalDebugMenu pref via the command line. (I don’t think you’ll need it, though.)
The new Network Timeline is pretty sweet, hit opt-cmd-n to bring it up. Click on the file name to view the file, click on the rest of the line to see the request and response headers.
.au Sprint
Eric Hodel | Tue, 11 Mar 2008 09:16:16 GMT
I spent Saturday and Sunday at the Sydney Rubinius sprint, and it was quite productive. Not only were local beers sampled, but we also got some good work done.
Lincoln Stoll helped me shake the last bugs out of RubyGems, so we integrated it into Rubinius. We decided to make it a subcommand rbx gem like rbx compile or rbx describe. There are still a few things broken in RubyGems, namely installing gems with extensions because mkmf.rb doesn’t work in Rubinius.
Lincoln also pointed out and gave me patches for a few backwards-compatibility problems with RDoc, so now both RubyGems and RDoc work on Rubinius.
Upon my return next week I’ll be cooking up a release of RubyGems with a handful of bug fixes and persistent connection support for RubyGems’ HTTP fetching which will make those incremental updates quite a bit faster.
An RDoc Wiki
Eric Hodel | Fri, 15 Feb 2008 00:14:37 GMT
For fun, I wrote a 200 line wiki a couple of weeks ago using WEBrick and RDoc withRCS as the only external dependency for history. You’ll need a recent build of Ruby 1.9 or Rubinius to run it:
It uses RDoc’s markup for formatting, and stores its content into ~/.rdocwiki as plain text files.
RdocWiki has one special page, /WikiCss that you can use to style things, here’s what I used:
#wiki_edit textarea {
width: 40em;
height: 20em;
}
#wiki_edit input {
display: block;
}
#wiki_restore {
display: inline;
}
I’d run a copy on Rubinius for you to use, but currently Rubinius is broken on FreeBSD.
RubyGems in Rubinius
Eric Hodel | Thu, 14 Feb 2008 23:58:00 GMT
Last night I checked an improved version of Zlib into Rubinius, and now gems can be installed:
$ ~/Links/RUBINIUS/shotgun/rubinius \
-Ilib bin/gem install rake --no-ri --no-rdoc -i ~/tmp/rbxgems
Successfully installed rake-0.8.1
1 gem installed
$ GEM_HOME=~/tmp/rbxgems ~/Links/RUBINIUS/shotgun/rubinius \
-Ilib ~/tmp/rbxgems/bin/rake --help
rake [-f rakefile] {options} targets...
Options are ...
[...]
Building the ri and RDoc information doesn't work correctly yet on Rubinius, but Rubinius is now using RDoc to generate some documentation, particularly the VM opcode information (run `rake doc:vm` in a Rubinius checkout).
Next I'm going to work on the RDoc/ri end of things some more, including improving or importing more documentation into Rubinius, and make a release of my recent RDoc changes.
Rubinius' Foreign Function Interface
Eric Hodel | Tue, 15 Jan 2008 09:22:00 GMT
I really, really, really love Rubinius’ Foreign Function Interface (FFI) since it allows you to replace C code with Ruby code. Earlier today I wrote Socket::getaddrinfo in C for Rubinius, and just now I finished a rewrite using FFI and Ruby. I’ve commented the code for clarity.
def self.getaddrinfo(host, service, family = nil, socktype = nil,
protocol = nil, flags = nil)
service = service.to_s
# MemoryPointer.new is kind-of like malloc(3), but understands what's inside
hints_p = MemoryPointer.new Socket::Foreign::AddrInfo.size
# Socket::Foreign::AddrInfo is a struct addrinfo wrapper with friendly accessors
hints = Socket::Foreign::AddrInfo.new hints_p
hints[:ai_family] = family || 0
hints[:ai_socktype] = socktype || 0
hints[:ai_protocol] = protocol || 0
hints[:ai_flags] = flags || 0
# getaddrinfo(3) asks for a struct addrinfo **.
# This creates a pointer to a pointer
res_p = MemoryPointer.new :pointer
# call out to C
err = Socket::Foreign.getaddrinfo host, service, hints_p, res_p
# check for errors
raise SocketError, Socket::Foreign.gai_strerror(err) unless err == 0
# now we read out the pointer that getaddrinfo() passed us, and cast it
# to a struct addrinfo *
res = Socket::Foreign::AddrInfo.new res_p.read_pointer
addrinfos = []
loop do
addrinfo = []
# Extract data
addrinfo << Socket::Constants::AF_TO_FAMILY[res[:ai_family]]
ai_sockaddr = res[:ai_addr].read_string res[:ai_addrlen]
sockaddr = Socket::Foreign::unpack_sa_ip ai_sockaddr, true
addrinfo << sockaddr.pop # port
addrinfo.concat sockaddr # hosts
addrinfo << res[:ai_family]
addrinfo << res[:ai_socktype]
addrinfo << res[:ai_protocol]
addrinfos << addrinfo
# struct addrinfo is a linked list, so if we've hit the end, stop
break unless res[:ai_next]
# otherwise, down the linked-list
res = Socket::Foreign::AddrInfo.new res[:ai_next]
end
return addrinfos
ensure
# like a C code, we have to free our MemoryPointer objects
hints_p.free if hints_p
if res_p then
# also, we have to do any C-side cleanup
Socket::Foreign.freeaddrinfo res_p.read_pointer
res_p.free
end
end
getaddrinfo(3), freeaddrinfo(3) and gai_strerror(3) are wrapped up by FFI like this:
attach_function "gai_strerror", :gai_strerror, [:int], :string
attach_function "getaddrinfo", :getaddrinfo,
[:string, :string, :pointer, :pointer], :int
attach_function "freeaddrinfo", :freeaddrinfo, [:pointer], :void
The first argument is the C function name, the second is the Ruby name, the third is the input arguments, and the fourth is the return type. Currently, FFI can only wrap up C functions with six or fewer args.
The AddrInfo struct is wrapped up like this:
class AddrInfo < FFI::Struct
config("rbx.platform.addrinfo", :ai_flags, :ai_family, :ai_socktype,
:ai_protocol, :ai_addrlen, :ai_addr, :ai_canonname, :ai_next)
end
The config method pulls pre-generated struct information out of a Rubinius config file and hooks up accessors to each of the struct’s fields. The accessors know which offset into the struct the data lives at and what type to convert data from and to when working with the struct. The information is collected at Rubinius build time by a small bit of C code.
I still have some confusion between passing an FFI::Struct like Socket::Foreign::AddrInfo vs. passing a MemoryPointer instance (which is what an FFI wrapped function understands) to an FFI-wrapped function, so we’re going to clean up that part of the API to make it more natural. Instead you’ll be able to initialize an FFI::Struct directly and pass it to the FFI-wrapped function. This will make the code quite a bit cleaner.
RubyGems on Rubinius
Eric Hodel | Sun, 13 Jan 2008 06:36:00 GMT
Friday I passed an important milestone for RubyGems on Rubinius, test/test_gem.rb ran to completion! Here are the dots to prove it:
$ ~/Links/RUBINIUS/shotgun/rubinius -Ilib:test test/test_gem.rb Loaded suite test/test_gem Started ................................. Finished in 18.667198 seconds. 33 tests, 56 assertions, 0 failures, 0 errors
These tests include building, installing, and activating a Gem, so it should be possible now to use RubyGems in Rubinius. Unfortunately, the `gem` command doesn't work yet. That will be among my next tasks.
The final holdup for these RubyGems tests was a Dir.glob that handled {}. Finishing this off should also allow rake to work, according Evan's recent work on rake.
A full run of all RubyGems tests reports:
100 tests, 221 assertions, 6 failures, 13 errors
A full run with MRI is 533 tests, 1816 assertions. The 433 missing tests are due to a missing feature of Module#module_function in Rubinius that prevents the remaining test files from loading.
If you'd like to duplicate my results, here's how:
- Checkout Rubinius
- Build Rubinius by running rake
- Checkout RubyGems' trunk
- Run /path/to/rubinius/shotgun/rubinius -Ilib:test test/test_gem.rb
"What should I work on in Rubinius?"
Eric Hodel | Thu, 10 Jan 2008 07:23:35 GMT
Occasionally, people drop into the Rubinius IRC channel and ask what they should work on. The answer in the past has been, “write some specs” which can be some terribly boring work and is not very motivational. Fortunately, I have a solution for that.
I think the best way to get involved in Rubinius is to take your favorite Ruby project and try to run it on Rubinius. Whatever problem you run into first, fix that (including writing specs, of course).
My work on running RubyGems in Rubinius has involved running the RubyGems tests, seeing where they fail, then moving over to Rubinius and fixing whatever failure I’m having. This way I’m highly motivated because my end goal, making RubyGems work, is easily in sight. (Of course, when RubyGems is working, I’ll need a new goal, maybe RDoc).
RDoc's TemplatePage removed from Ruby
Eric Hodel | Mon, 07 Jan 2008 10:59:54 GMT
If you’ve got a custom RDoc template, it won’t work with the next release of 1.9. I’ve removed the custom TemplatePage and replaced it with an ERB-based version that works similarly.
This should make it much, much easier to write a custom RDoc template as you can now use arbitrary ruby code inside your templates.
It’s really easy to convert an old RDoc template to the upcoming version:
| Replace this | With this |
|---|---|
%blah% | <%= values["blah"] %>
|
!INCLUDE! | <%= template_include %>
|
HREF:aref:name | <%= href values["aref"], values["name"] %>
|
IF:blah | <% if values["blah"] then %>
|
IFNOT:blah | <% unless values["blah"] then %>
|
ENDIF:blah | <% end %>
|
START:blah | <% values["blah"].each do |blah| %>
|
END:blah | <% end %>
|
To make nested loops easier to convert, convert START statements to:
<% values["blah"].each do |blah| $stderr.puts blah.keys %>
So you can see what is being used inside which loop.
I’ve also removed the old_html template, as I don’t think anybody uses it anymore, and updated all the existing templates in RDoc to use ERB. (If somebody could double-check my work on the CHM and XML outputters, that would be great.)

Articles