I was attempting to build a roc binary and reached for a command line argument -o
but we dont support roc build -o output input.roc
. Just wondering why that is? Is it strange that the output binary is determined in the file?
This is similar to most build systems: cargo
in rust, cmake
or make
(I think zig build
where it would be defined in build.zig
).
I think it is a question of if you see roc
as a build coordinator/system or something that should compile individual files...
But that is just my guess.
I don't have a strong opinion here, just noticed this while I was working on something. I have written another app which compiles some roc script files, but don't have a good way to know what the resulting binary will be called or where it will be located. I may be approaching this the wrong way, basically I'm experimenting with a CGI server which on load compiles all the "scripts" into binaries, and then on a request calls the roc binary/executable.
I've actually been thinking about switching to this
right now it's defined in the app
module
e.g. app "mybinaryname"
that design is from ~2019 and I think maybe doing it at the command line might make more sense
@Richard Feldman would you accept a PR for this change, or do we need more discussion to understand the implications? Do you have any thoughts on removing the app name string from the module header? I can create an issue to track this, and reference this conversation.
If no "-o" is provided would we then default to the filename without ".roc"?
Anton said:
If no "-o" is provided would we then default to the filename without ".roc"?
that sounds good - and with .exe
on Windows
yeah I think PR is fine!
@Anton I believe that once you have this PR you will fix the issue I opened a few minutes ago about empty app names, or even worse, app names with paths on it :sweat_smile:
So it is indeed important to implement the "if no -o
is provided, we default to the filename (instead of the app name) :+1:
Thanks for alerting us to the security issue @Fábio Beirão, I've made issue #5501 for first step fix. I've marked it an intermediate issue because I don't think it will be complicated but familiarity with the code base will make it easier. If no one wants to take it, I will.
Last updated: Jul 06 2025 at 12:14 UTC