Skip to content

Make roc check automatically search for a root app/package/platform file #6538

@faldor20

Description

@faldor20

Currently when running roc check on interface files that import a platform or package eg import [pf.Stdout] the checking will fail because we don't know where to get the package or platform from.

After discussing here https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/package.20shorthands.20when.20compiling.20interface.20modules

We concluded we should be able to find the file that the interface is imported by following some simple rules:

"app, package, and platform modules can only import other modules if they are named exactly main.roc, but otherwise they can be named anything. Normal modules can be named anything and can still import each other."
"the default file to look for is named main.roc, but that can be configured in the editor"

This means, the roc cli and the language server can make the following assumptions:

  1. Scripts, which would regularly not be named "main.roc" cannot have imports and this doesn't require changing language server settings. We can assume, as the language server or roc cli, anything not named "main.roc"(or your configured main name) doesn't have imports.
  2. If we don't see a "main.roc"(or your configured main name) in the current directory, in a valid project we should expect to be able to walk up directories to find one.

So this requires the following changes:

  1. When running roc check against an interface with a package import we should look for main.roc and use it's package versions to resolve that package. The cli should allow the user to specify this if they wish if they are using a different name for their main file. eg: roc check myInterface.roc --main app
  2. The language server should make any changes needed to ensure this works there too.
  3. The language server should have an option to set the name of the file that we expect to be the main file. So if instead of main.roc someone wants "app.roc" they can configure that.
  4. Adjust or remove the error message added here: https://github.com/roc-lang/roc/pull/6361/commits

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions