Arc Forumnew | comments | leaders | submitlogin
Please test: expanding user directories
3 points by zck 1293 days ago | 5 comments
I've been annoyed that Arc doesn't let you open files beginning with ~ on Linux/Mac systems. So I fixed that, using Racket's expand-user-path: https://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._expand-user-path%29%29

It should continue to work fine on Windows as well, but I'd love to have someone test it there. Test instructions in the pr.

PR here: https://github.com/arclanguage/anarki/pull/206



3 points by jsgrahamus 1273 days ago | link

  Sorry it took so long.

  Running on Windows 10 Home, and Racket v8.0[cs (Downloaded 1 day ago)]:
  arc> (outfile "~/test.txt")
  expand-user-path: bad username in path
    path: ~/test.txt
    system error: unsupported; rkt_err=1
    context...:
     body of "D:\Steve - D\Documents - D\git\anarki\ac.rkt"
     D:\Steve - D\Documents - D\git\anarki\ac.rkt:1014:14: outfile
     D:\Steve - D\Documents - D\git\anarki\ac.rkt:1459:4

  arc> (outfile "~\test.txt")
  expand-user-path: bad username in path
    path: ~       est.txt
    system error: unsupported; rkt_err=1
    context...:
     body of "D:\Steve - D\Documents - D\git\anarki\ac.rkt"
     D:\Steve - D\Documents - D\git\anarki\ac.rkt:1014:14: outfile
     D:\Steve - D\Documents - D\git\anarki\ac.rkt:1459:4

  arc> (outfile "~\\test.txt")
  expand-user-path: bad username in path
    path: ~\test.txt
    system error: unsupported; rkt_err=1
    context...:
     body of "D:\Steve - D\Documents - D\git\anarki\ac.rkt"
     D:\Steve - D\Documents - D\git\anarki\ac.rkt:1014:14: outfile
     D:\Steve - D\Documents - D\git\anarki\ac.rkt:1459:4

  arc>

-----

3 points by rocketnia 1271 days ago | link

If I understand right, I think those are supposed to be errors still. The documentation for `expand-user-path` says "In addition, on Unix and Mac OS, a leading ~ is treated as user’s home directory and expanded[...]" but it doesn't say there's any corresponding behavior on Windows.

-----

3 points by zck 1270 days ago | link

Ah, interesting. That's a good point that it's Unix/MacOS-specific. My hope was that it should make Arc interpret paths the same way the default shell on the system does. On Linux, ~/ is the home directory of the current user, so it makes sense that Anarki would work that way on Linux. But Windows doesn't work that way, so it makes sense Anarki wouldn't either.

I don't know of any similar path tricks on Windows, But, if this change hasn't broken anything on Windows, I would be satisfied with that. Can you verify it still works to open an existing file? Are there any other special ways to refer to files or directories on Windows?

-----

2 points by rocketnia 1264 days ago | link

"On Linux, ~/ is the home directory of the current user, so it makes sense that Anarki would work that way on Linux. But Windows doesn't work that way, so it makes sense Anarki wouldn't either."

Yeah, I don't know much about what a Windows user would expect ~ to do. I would say `expand-user-path` leaving ~ alone on Windows is probably as good a behavior as any. It coincides with Command Prompt, where ~ just refers to a file or folder named "~". In PowerShell, ~ seems to be expanded to C:\Users\[username]\ somehow, so there's potentially an alternative design there.

---

"I don't know of any similar path tricks on Windows, But, if this change hasn't broken anything on Windows, I would be satisfied with that. Can you verify it still works to open an existing file?"

On Windows 10 64-bit with Racket 8.1, I've at least run the tests.arc unit tests, the unit-test.arc/tests.arc unit tests, and build-web-help.arc, and they seem to work.

---

"Are there any other special ways to refer to files or directories on Windows?"

Racket deals with a lot more Windows path features than I've ever learned about or encountered, and there's some gritty documentation of that here: https://docs.racket-lang.org/reference/windowspaths.html

I hardly know where to begin learning about and testing those features, and the documentation makes it look like Racket has explored hat rabbit hole pretty thoroughly already, so I'm inclined to suggest we just piggyback on Racket's work here.

-----

2 points by jsgrahamus 1273 days ago | link

Downloaded anarki to C:\Users\Steve\Downloads" and tried it.

Got same results.

-----