Stream: beginners

Topic: How to debug


view this post on Zulip Eelco Hoekema (Dec 07 2023 at 18:02):

How does one debug in Roc?

I noticed some examples in the tutorial using dbg, but i see no output in the terminal when i use that. Do i need a flag enabled?

view this post on Zulip Brendan Hansknecht (Dec 07 2023 at 18:03):

dbg should print if you run an application with roc ... or roc dev ....

view this post on Zulip Brendan Hansknecht (Dec 07 2023 at 18:03):

This will run in more cases in the future, but is currently limited

view this post on Zulip Ryan Bates (Dec 07 2023 at 18:09):

@Eelco Hoekema If you are on an older nightly build (before Dec) and running roc test it won't print dbg output. Try installing the latest nightly for this.

view this post on Zulip Eelco Hoekema (Dec 07 2023 at 20:36):

I am running latest - but don't see anything out of dbg, neither with roc run, nor with roc dev or roc test.

view this post on Zulip Elias Mulhall (Dec 07 2023 at 20:42):

what's your code look like? It could be the opposite problem where you're running the most recent version of roc but an old version of a platform.

view this post on Zulip Eelco Hoekema (Dec 07 2023 at 20:45):

I am using an AoC template of @Luke Boswell .

Starting with this:

app "AoC"
    packages {
        pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.0/bkGby8jb0tmZYsy2hg1E_B2QrCgcSTxdUlHtETwm5m4.tar.br",
        parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.2.0/dJQSsSmorujhiPNIvJKlQoI92RFIG_JQwUfIxZsCSwE.tar.br",

    }

and

part1 : {} -> Result Str [NotImplemented, Error Str]
part1 = \_ ->
    dbg "hello"

    lines testset
        |> List.map parseLine
        # |> List.keepIf gameIsValid
        # |> List.map .id
        # |> List.map Num.toStr
        |> List.map .cubes
        |> List.map cubesListToStr
        |> Str.joinWith "\n"
        |> Ok

view this post on Zulip Eelco Hoekema (Dec 07 2023 at 20:45):

(not making much progress with AoC, yet still having a lot of fun with the language)

view this post on Zulip Elias Mulhall (Dec 07 2023 at 21:25):

hmmmmm, still not totally sure what's up

view this post on Zulip Luke Boswell (Dec 07 2023 at 21:43):

If you can share your code, I can probably help you more. I don't see any issues with what you have shared, it looks like it should work. BTW super happy to see people are using that :grinning_face_with_smiling_eyes: I've got a bunch of improvements I really should push to update the template. :sweat_smile:

view this post on Zulip Eelco Hoekema (Dec 07 2023 at 21:54):

My github

view this post on Zulip Luke Boswell (Dec 07 2023 at 21:56):

I might need 45mins, just out grabbing a coffee.

view this post on Zulip Eelco Hoekema (Dec 07 2023 at 21:56):

Well, thanks for sharing that template, got me started quite quickly. Really like how the language is now.

view this post on Zulip Eelco Hoekema (Dec 07 2023 at 21:59):

I am in a timezone where it is time to go to sleep. So don't worry. Also, please don't feel obliged.

view this post on Zulip Luke Boswell (Dec 08 2023 at 00:26):

I cloned your repository and tested it and it works for me. I'm wondering what system you are running? Maybe that might explain it?

$ roc dev src/cli.roc -- 2023 2
Running Part 1...[src/S2023/D02.roc:19] "hello"
done
Running Part 2...done
---------------------------------
Solution for 2023 Day 2: Cubes Conundrum
---------------------------------
year: 2023
day: 2
total time: <0

Part 1 calculated in <0 ms
---------------------------------
0:0:0 - 0:0:0 - 0:0:0
0:0:0 - 0:0:0 - 0:0:0
0:0:0 - 0:0:0 - 0:0:0
0:0:0 - 0:0:0 - 0:0:0
0:0:0 - 0:0:0

Part 2 calculated in <0 ms
---------------------------------
not yet implemented

view this post on Zulip Eelco Hoekema (Dec 08 2023 at 06:22):

Hmm. Funny. Running Mac OS Ventura 16.2. But it is a slightly locked down one, as it is my work macbook. Will try on linux later today.

view this post on Zulip Artur Domurad (Dec 08 2023 at 08:00):

So roc test should also print dbg statements? :astonished:
This doesn't work for me on MacOS and on Linux...
It only works when I use roc dev ...

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 15:31):

Depending on when you last updated roc, it may just be too old to have the feature. That or there is a bug with it.


Last updated: Jul 05 2025 at 12:14 UTC