Skip to content

Conversation

@YanniPapandreou
Copy link

Description

Closes #8549.

As described in the above issue when running the roc compiler on a main.roc with a platform specified as an absolute file path:

app [main!] { pf: platform "/Users/yanni/projects/roc-platform-template-zig/platform/main.roc" }

import pf.Stdout
import pf.Stdin

main! = |_args| {
    Stdout.line!("What's your name?")
    name = Stdin.line!()
    Stdout.line!("Hello, ${name}!")
    Ok({})
}

I obtained the following error:

$ ./zig-out/bin/roc --no-cache main.roc
error: No platform found. Every Roc app requires a platform.
error: Failed to set up shared memory with ModuleEnv: error.NoPlatformFound

With this PR I know get this error message, indicating that absolute paths are not allowed:

error: No platform found. Absolute paths are not allowed for platform specification: "/Users/yanni/projects/roc-platform-template-zig/platform/main.roc"
error: Failed to set up shared memory with ModuleEnv: error.NoPlatformFound

Checks

  • I've build and tested the roc compiler on the program above.
  • I've run the tests with zig build snapshot && zig build test and they all passed.

Improves error message when platform is wrongly specified by an absolute
path
Copy link
Collaborator

@Anton-4 Anton-4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing @YanniPapandreou :)
Could you add a tip as well stating that people should instead use relative paths like ../platform or a URL?

@YanniPapandreou
Copy link
Author

YanniPapandreou commented Dec 5, 2025

Thanks for contributing @YanniPapandreou :) Could you add a tip as well stating that people should instead use relative paths like ../platform or a URL?

Sure would something like this be better - I've pushed a change. Here is the error message now:

error: No platform found. Absolute paths are not allowed for platform specification: "/Users/yanni/projects/roc-platform-template-zig/platform/main.roc". Please use a relative path like `./path/to/platform` or a URL.
error: Failed to set up shared memory with ModuleEnv: error.NoPlatformFound

On smaller terminals it wraps to the next line as shown in picture below:

Screenshot 2025-12-05 at 18 40 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message when platform is specified as an absolute path

2 participants