Hi, I'm using the latest roc nightly build (commit c6089eb on Mo 20 Feb 2023) and trying to build an app that imports a local library.
My folders are laid out like this:
.
├── bin
│ └── main.roc
└── MyLib
└── main.roc
With this in the MyLib/main.roc
:
package "MyLib"
exposes [greet]
greet = \person -> "Hello, \(person)!"
And this in the bin/main.roc
:
app "Hello"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.2.0/8tCohJeXMBUnjo_zdMq0jSaqdYoCWJkWazBd4wa8cQU.tar.br",
MyLib:"../MyLib/main.roc"
}
imports [pf.Stdout, MyLib.{greet}]
provides [main] to pf
main =
pf.Stdout (greet "world")
I'm running this command to try and build the app:
roc dev bin/main.roc
but I get this error:
thread 'main' panicked at 'not yet implemented: unhandled parse error ListEnd(@161)', crates/reporting/src/error/parse.rs:3794:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
which seems to suggest some feature I'm using is not implemented, but I'm not sure which one.
Thanks in advance!
I think the MyLib
header needs to be:
package "MyLib"
exposes [greet]
packages {}
I'll check locally to confirm
Thanks for your help Anton, I tried adding packages {}
to the MyLib/main.roc
file, but I'm still getting the same error, is it the same for you?
Yes, it's the same for me. I have to go out for about an hour, I'll investigate further when I'm back.
I got it to work with the following modifications:
package "MyLib"
exposes [ Greeter ]
packages {}
And I made a new file in the MyLib folder called Greeter.roc:
interface Greeter
exposes [ greet ]
imports []
greet = \person -> "Hello, \(person)!"
I'm not sure if package modules are supposed to support functions in the file but I'll make an issue to improve the error message.
Thanks Anton, can you share what your bin/main.roc
looks like please? I tried making the changes you suggested, but I'm still getting the same error for some reason
Oh right, I forgot about the import change in bin/main.roc
, I've deleted the file now but I think this should work:
imports [pf.Stdout, MyLib.Greeter.{greet}]
Thanks, I'm having trouble building the app when I include MyLib: "../MyLib/main.roc"
in the list of packages. If I rearrange the files to be like this:
.
├── main.roc
└── MyLib
├── Greeter.roc
└── main.roc
and I remove the MyLib
entry from the list of packages then I can import MyLib
into the app.
I know the Roc compiler has rules about finding modules by looking for a file called MyLib.roc
and MyLib/main.roc
, but do you know if it's possible to use the packages
list to tell the Roc compiler to look in a different folder for the library?
Yes, the approach you were using with the ../
was working for me. I'll set up and test a folder locally and send you a compressed archive.
Thank you! Which version of the Roc compiler are you using? I hope it's not a version mismatch error! :sweat_smile:
I'm testing with the latest main, built from source. If you still have problems with my archive, I can check with your version but I don't think that's likely unless your version is say months old.
Okay, I'm using the nightly from 20th February, so should be all good :)
Now I can't get back to my working version :p I'll figure it out though...
Haha, I'll pick this up again tomorrow, thanks for your help :+1:
Alright here it is: parse_error.tar.gz
So all changes required compared to the original:
packages {}
to MyLib/main.roc
Greeter.roc
bin/main.roc
rename MyLib
to myLib
, it has to be lowercasemain = pf.Stdout ( greet "world" )
it should be main = Stdout.line (greet "world")
Oh, this is the issue where only for packages, exposes means something different. For packages, you can't expose functions or types directly, you have to expose interfaces in another file. Those can then expose functions and types.
I think we really need to fix the naming here to make this clearer. Or change the semantics or something
What is a package? I’ve only seen Interface before
I think package is for when you want to make a pure roc "library".
@Hannes your example revealed 4 different cases where error messages could be improved so thank you as well :)
Thanks Anton for all your help, I was really confused by why it would sometimes work and other times would error. I 'll look at the Roc compiler code and might try contributing fixes for some of these problems :)
There is only a very brief description of the modules in the tutorial at the moment. Linking here for anyone who finds this thread.
Each .roc file is a separate module and contains Roc code for different purposes. Here are all of the different types of modules that Roc suppports;
Last updated: Jul 06 2025 at 12:14 UTC