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?
dbg
should print if you run an application with roc ...
or roc dev ...
.
This will run in more cases in the future, but is currently limited
@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.
I am running latest - but don't see anything out of dbg, neither with roc run, nor with roc dev or roc test.
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.
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
(not making much progress with AoC, yet still having a lot of fun with the language)
hmmmmm, still not totally sure what's up
roc check
coming back clear?part1
getting called from main
?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:
I might need 45mins, just out grabbing a coffee.
Well, thanks for sharing that template, got me started quite quickly. Really like how the language is now.
I am in a timezone where it is time to go to sleep. So don't worry. Also, please don't feel obliged.
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
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.
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 ...
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