Arc Forumnew | comments | leaders | submitlogin
Beginner Question: cannot open input file
1 point by Andrew_Quentin 4973 days ago | 3 comments
cannot open input file "C:/dev/urandom"

I am using windows by the way.

When I try and create a dev/urandom, the error turns to denied access. I suspect that is because folders are read only. However, when the mkdir function is used so that arc creates the necessary directories itself, it does not seem to have any problem with writing files on there.

I am therefore slightly confused. Maybe, before I even manage to load the blog and news, I should try and get accustomed to the code, rather than do so on the go as I thought I might. I am thinking, the problem might be resolved by possibly defining "input-file" so that if it exists file is used, but if not mkdir and thereafter, replace dev/urandom with "input file"

Has anyone else encountered this problem and have you solved it?



2 points by fallintothis 4973 days ago | link

/dev/urandom is a special file in Unix-like operating systems that spits out random bits (see http://en.wikipedia.org/wiki//dev/random). Arc isn't so great at the cross-platform thing, since it hard-codes Unix-like paths & shell commands. In this case, srv.arc breaks when trying to generate a random string because it calls rand-string from arc.arc, which tries to open /dev/urandom to get random data. The file doesn't exist in Windows (and just creating one won't do the job, since Windows doesn't say "hey, I know, I'll generate random bits when people read from this file"), hence the error.

This was discussed awhile back in a thread that has some fixes for other Windows issues: http://arclanguage.org/item?id=9263.

-----

1 point by Andrew_Quentin 4973 days ago | link

Hey. Thanks a lot for your reply. Are you speaking of this solution: http://jfkbits.blogspot.com/2008/01/digging-into-arc-in-24-m...

It seems to work fine if you take off the 'before make directory, but what exactly do I do with dev/urandom in both ac.scr and arc.arc?

-----

3 points by fallintothis 4973 days ago | link

Are you speaking of this solution

Well, strictly I was speaking of the solutions in the thread that I linked to, but that blog post is about the issue they discussed.

It seems to work fine if you take off the 'before make directory

Yeah, those forum/blog posts were from quite awhile ago, when xdef expected its first argument to be quoted (see http://ycombinator.com/arc/tut.txt -- or any of the myriad other Lisp tutorials out there -- for an introduction to quoting).

but what exactly do I do with dev/urandom in both ac.scr and arc.arc?

I linked to that thread because it was relevant, though it didn't fix this specific bug: it's still true that pg expects Windows snafus to be fixed downstream. As rocketnia mentioned (http://arclanguage.org/item?id=12397), most seem to be solved by using Cygwin, which will give you /dev/urandom & such.

The outstanding issues I'm aware of are generally fixable outside of Cygwin, but would require a bit of code drudgery.

- The setuid bug, apparently fixed (by doing nothing when it's called, so I'm suspicious, but I don't know): http://arclanguage.org/item?id=10625.

- pipe-from in ac.scm runs rm -f, which could be replaced by Racket's delete-file wrapped in the proper error-catching code (http://docs.racket-lang.org/reference/Filesystem.html#%28def...). It also uses /dev/urandom to generate a random filename, but that could be replaced by Racket's make-temporary-file (cf. http://arclanguage.org/item?id=2333 and http://docs.racket-lang.org/reference/Filesystem.html#%28def...).

- shash in arc.arc just uses openssl, which has a Windows binary that should work. It worked a few years ago, anyway: http://arclanguage.org/item?id=190. shash also creates a file in /tmp/, but that shouldn't be an issue, if I recall correctly from the few times I've run Arc on Windows.

- ensure-dir in arc.arc has been patched in that thread I linked to -- again, just using Racket's functions.

- load-items in news.arc has

  (system (+ "rm " storydir* "*.tmp"))
which seems like it could be done with Racket's delete-file and find-files (http://docs.racket-lang.org/reference/Filesystem.html#%28def...).

- rand-string uses /dev/urandom, which takes a little more doing to fix, as evidenced by the lack of changes on Anarki (the community-maintained repository for changes to Arc: http://github.com/nex3/arc). You might could rewrite it to use Racket's random number generators, but I don't really know.

-----