Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createDirectory inconsistency between runtimes #5501

Open
ceedubs opened this issue Dec 12, 2024 · 0 comments
Open

createDirectory inconsistency between runtimes #5501

ceedubs opened this issue Dec 12, 2024 · 0 comments
Assignees
Labels

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Dec 12, 2024

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 ceedubs added the bug label Dec 12, 2024
@dolio dolio self-assigned this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants