unison icon indicating copy to clipboard operation
unison copied to clipboard

createDirectory inconsistency between runtimes

Open ceedubs opened this issue 10 months ago • 0 comments

Describe and demonstrate the bug

In the Haskell interpreter, createDirectory acts like Unix's mkdir -p, creating parent directories as needed. But in the scheme runtime, createDirectory fails if a parent directory doesn't exist.

I'm not sure that one approach is more right than the other, but they should at least be consistent. And at this point the path of less resistance might be to make the scheme runtime match the behavior of the Haskell interpreter since the latter is already used more widely. But I don't have particularly strong feelings about that.

You can observe the difference by running the following program with both run and run.native:

main = do
  use FilePath /
  dir = getTempDirectory() / "foo"
  Debug.trace "dir is" dir
  if isDirectory dir then
    Debug.trace "already existed" dir
  else
    Debug.trace "creating" dir
    createDirectory dir
    Debug.trace "created" dir

Screenshots

scratch/main> run main                            
trace: dir is
FilePath "/tmp/unison/nix-shell.wZlII7/foo/bar"
trace: creating
FilePath "/tmp/unison/nix-shell.wZlII7/foo/bar"
trace: created
FilePath "/tmp/unison/nix-shell.wZlII7/foo/bar"
  
  ()                                                                                                      

scratch/main> run.native main
trace: dir is                                                                                             
{Data #i734n6np 0 {"/tmp/unison/nix-shell.wZlII7/foo/bar"}}
trace: creating
{Data #i734n6np 0 {"/tmp/unison/nix-shell.wZlII7/foo/bar"}}
make-directory: cannot make directory
  path: /tmp/unison/nix-shell.wZlII7/foo/bar
  system error: No such file or directory; errno=2
  context...:                
   .../unison/boot.ss:287:11
   .../unison/curry.rkt:101:32                                                                            
   .../unison/boot.ss:231:9: ref-02mesa0dv60bbdpspnguivjbf5vkbnu2jdohs18non02bncmuj0l0:impl
   .../unison/boot.ss:231:9: ref-02abd75a0lohs6p88ah1g6153891prfdju4t4s6frntpkq635fhqs:impl
   .../racket/control.rkt:137:30
   .../racket/unison-runtime.rkt:190:2                                                                    
   body of '#%mzc:unison-runtime
    
  native evaluation failed

Environment (please complete the following information):

  • ucm --version 0.5.29
  • OS/Architecture: x86 linux

Additional context

This came up in the Advent of Code client, which creates subdirectories in the tmp dir for caching. https://discord.com/channels/862108724948500490/1316532667231240264

ceedubs avatar Dec 12 '24 14:12 ceedubs