Stream: beginners

Topic: Roc hangs when i try to import a module?


view this post on Zulip Asbjørn Olling (Dec 04 2023 at 21:54):

I tried splitting my advent of code code into a module, to try and make one program that runs all of my solutions.
I made an interface of todays solve and called that from a main.roc in the same folder, and that worked fine.
Then I made a main.roc in the parent folder, and try to import that same interface (making sure to rename it according to its' path)- but now when I call roc dev in my repo root, roc just hangs.
I tried letting it run for several minutes but ehhh.. I'm pretty convinced it's not getting anywhere. It's less than 200 lines of code.

Repo to reproduce (on the modularize branch):
https://gitlab.com/AsbjornOlling/aoc2023/-/tree/modularize

It hangs when I run roc dev in the repo root using the roc from the nix flake shell (should be latest main).

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 21:57):

If I comment out D04.Solution from the imports in :/main.roc, it runs fine.

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 21:58):

Feels like a bug in resolving imports? Let me know if I should just open a github issue.

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 21:59):

does roc build hang as well?

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:00):

yup. roc build as well

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:00):

they all hang while consuming 100% of one core

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:01):

...and actually the roc_ls language server that emacs is running hangs as well, using 100% of one core

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:04):

roc test D04/Solution.roc hangs as well. so probably something funky in the interface file

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 22:06):

cool. Sounds like a proper bug. I wonder what kind of silly thing we are doing/looping on the imports

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 22:07):

Can you file an issue. If possible a minimal repro is always amazing, but filing everything is also great.

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:17):

I'll file an issue :sparkles:

I started ripping away code, and got down to this minimal repro:

in a folder with only this file, running roc test Solution.roc

interface Solution
    exposes [a]
    imports [
        parser.Core
    ]

a = 2

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:23):

I filed #6185

view this post on Zulip Agus Zubiaga (Dec 04 2023 at 22:24):

Try roc check. I have seen that work when the other commands hang.

view this post on Zulip Asbjørn Olling (Dec 04 2023 at 22:33):

roc checkalso hangs

view this post on Zulip Asbjørn Olling (Dec 05 2023 at 10:58):

FWIW, I tried going back in the roc repo history to see how far back I can reproduce this bug, and the bug seems to be older than one year, and probably also older than the first commit where nix build works in the repo flake :sweat_smile:

view this post on Zulip Asbjørn Olling (Dec 05 2023 at 11:01):

I wanted to try and see if I could fix it myself (I probably can't, but I'll give it a shot!), by finding a commit where it works, and doing a git bisect dance from there. But I got stuck trying to build old versions of roc.

view this post on Zulip Brendan Hansknecht (Dec 05 2023 at 17:19):

It probably is just a parser assumption that is wrong from when the parse was first written

...actually, it hangs, so probably an issue in file.rs and the loading logic.

view this post on Zulip Brendan Hansknecht (Dec 05 2023 at 17:20):

Probably the best way to figure out what is going on:

  1. debug build compiler
  2. run the command with gdb or lldb
  3. ctrl + c after a bit of wait
  4. bt to get a backtrace
  5. start debugging from that backtrace. Something in that chain is probably the issue.

Last updated: Jul 06 2025 at 12:14 UTC