Thu 22 Mar 2007
More Ruby fun – uuidtools and uuid gems and Mac Addresses
Posted by dustin under Uncategorized1 Comment
Be careful if running your ruby application in a VPS that doesn’t have a standard MAC address (OpenVZ/Virtuozzo).
[rails@rails ~]$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'uuidtools'
=> true
irb(main):003:0> UUID.timestamp_create
NoMethodError: private method `split' called for nil:NilClass
from /usr/local/lib/ruby/gems/1.8/gems/uuidtools-1.0.0/lib/uuidtools.rb:236:in `timestamp_create'
from /usr/local/lib/ruby/gems/1.8/gems/uuidtools-1.0.0/lib/uuidtools.rb:226:in `synchronize'
from /usr/local/lib/ruby/gems/1.8/gems/uuidtools-1.0.0/lib/uuidtools.rb:226:in `timestamp_create'
from (irb):3
irb(main):004:0>
UUID.random_create works though
irb(main):005:0> UUID.random_create
=> #&ls;UUID:0x20254aac UUID:debe5522-85e3-4119-8e31-5746f8f52449>
As a side note, the uuid gem has problems determining the MAC address when creating its state file as well.
-bash-3.00# uuid-setup
uuid: No UUID state file found, attempting to create one for you:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27: command not found: ipconfig /all
Could not find any IEEE 802 NIC MAC addresses for this machine.
You need to create the uuid.state file manually.
When using this I would manually create the uuid.state file and place it in /usr/local/lib/ruby/gems/1.8/gems/uuid-1.0.3 (I don’t remember exactly, and have since removedthe uuid gem). If you don’t your app will complain about the uuid.state file being missing.
One Response to “More Ruby fun – uuidtools and uuid gems and Mac Addresses”
Leave a Reply
You must be logged in to post a comment.
September 30th, 2008 at 5:38 am
This a good post ! I was stuck with the MAC address problem for a while but I am just wondering if one should be worried about collisions when using UUID.random_create. I have not got time to check the random generator being used.