Stream: beginners

Topic: List files in a directory


view this post on Zulip Sajjad Naveed (Jun 08 2024 at 18:23):

I am trying to build a simple cli tool (simple-cli) to list contents of a directory. But I am running into an issue with the only function listed in the documentation that could potentially help with this:

Dir.list

The documentation for the above method states that it takes Str as input. However, this results into an error from the compiler.

The argument is a string of type:

    Str

But list needs its 1st argument to be:

    InternalPath.InternalPath

Am I doing something incorrectly, here?

view this post on Zulip Sajjad Naveed (Jun 08 2024 at 18:25):

Here's the complete code:

app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }

import pf.Task
import pf.Dir
import pf.StdOut

main =
    entries = Dir.list! "/path/to/directory"
    dbg entries

    StdOut.line! "Finished scanning!"

view this post on Zulip Brendan Hansknecht (Jun 08 2024 at 18:47):

Our docs need versioning apparently

view this post on Zulip Brendan Hansknecht (Jun 08 2024 at 18:47):

0.10.0 Dir.list takes a Path

view this post on Zulip Brendan Hansknecht (Jun 08 2024 at 18:47):

So you would need Path.fromStr

view this post on Zulip Brendan Hansknecht (Jun 08 2024 at 18:47):

I think the docs online are now for 0.11.0 of basic cli

view this post on Zulip Brendan Hansknecht (Jun 08 2024 at 18:49):

@Anton any reason 0.11.0 is only a prerelease and not latest?

Also, url for 0.11.0: https://github.com/roc-lang/basic-cli/releases/download/0.11.0/SY4WWMhWQ9NvQgvIthcv15AUeA7rAIJHAHgiaSHGhdY.tar.br

view this post on Zulip Sajjad Naveed (Jun 08 2024 at 18:53):

Thanks @Brendan Hansknecht

view this post on Zulip Anton (Jun 10 2024 at 06:56):

The docs are already versioned.
Perhaps there was some old link that points to the docs of the main branch. Can you clarify how you ended up on the wrong docs site @Sajjad Naveed?

view this post on Zulip Anton (Jun 10 2024 at 06:59):

@Anton any reason 0.11.0 is only a prerelease and not latest?

0.11 contains some untested code, I'm almost done with setting up those tests.

view this post on Zulip Sajjad Naveed (Jun 10 2024 at 12:30):

@Anton I just followed the link from the roc-lang docs section but now it seems it's pointing to the updated docs. You can see the link above which I added in the post, previously it was showing list function (Dir) which took Str as the input but now it seems that has been fixed even on the link I shared.

view this post on Zulip Anton (Jun 10 2024 at 13:03):

Riight, that link, thanks! I'll make an issue to point that to the latest stable release.


Last updated: Jul 06 2025 at 12:14 UTC