Ruby Forum Ruby on Rails > Cygwin Rails issues "/dev/urandom" not found

Posted by jjburka (Guest)
on 13.12.2007 04:55
(Received via mailing list)
Hey,

I'm trying to install ruby on rails on windows xp with cygwin. I
installed the rails gem but when I go to create an application I get
the following : "No such file or directory - /dev/urandom"  the error
seems to be coming form secret_key_generator.rb line 22. But I can't
find a file of that name

Thanks
Posted by Marcin Jekot (marchi)
on 14.12.2007 15:10
Hi,

Apparently the /dev/urandom file does not 'exist' in cygwin, but you can 
do stuff with it, i.e. `cat /dev/urandom' (although don't try this, cos 
it tends to mess things up a bit).

In any case, things like File.exists?('/dev/urandom')  in 
'secret_key_generator.rb' file fail.

So I changed all the occurences of 'if File.exists?('/dev/urandom')' to 
'if true'. Still it would fail on: 'File.read("/dev/urandom", 
64).unpack("H*")[0]'

Now don't ask me why (it's only my 3rd day with Ruby, and 1st day with 
Rails), works for me if I put this line before the File.read() :

    def generate_secret_with_urandom
      puts "Before Read"
      return File.read("/dev/urandom", 64).unpack("H*")[0]
    end


et voila, it works. I don't know why it works (yet), but it does ;), I 
now have cygwin + ruby (the cygwin one) + gem + rails working.

I even checked if the "secret" returned is different every time, and it 
is. It's an oddity, and I'll have to fix it every time I update to a new 
version of Rails, but I'm hoping to be more of an expert by the time an 
update is released ;)

-Marcin Jekot

jjburka wrote:
> Hey,
> 
> I'm trying to install ruby on rails on windows xp with cygwin. I
> installed the rails gem but when I go to create an application I get
> the following : "No such file or directory - /dev/urandom"  the error
> seems to be coming form secret_key_generator.rb line 22. But I can't
> find a file of that name
> 
> Thanks
Posted by Lenart (Guest)
on 03.01.2008 17:06
(Received via mailing list)
What Marcin said works - I just wanted to simplify the steps:

1. locate the file secret_key_generator.rb inside cygwin directory (in
my case - c:\cygwin\lib\ruby\gems\1.8\gems\rails-2.0.2\lib
\rails_generator\)
2. find "def generate_secret_with_urandom" (line #85 in Rails 2.0.2)
3. copy the line just below "def generate_....":
    puts "Before Read"
4. save the file and it should work

Hope it helps