Skip to content

The //> using exclude directive is silently ignored when declared in any file other than project.scala #3385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks
Gedochao opened this issue Dec 20, 2024 · 4 comments
Labels
--exclude Issues tied with the excluding inputs. bug Something isn't working documentation Improvements or additions to documentation

Comments

@Gedochao
Copy link
Contributor

Version(s)
1.5.4 and 4ab3227

Describe the bug
If the //> using exclude (..) directive is declared anywhere but project.scala, it gets ignored completely, with no warning.
While we do not want it declared in other files (and that is intended), we should communicate it better in our docs as well as actually warn users about it being ignored.
The current behaviour is very confusing.

To Reproduce
Try to use the //> using exclude directive in any file other than project.scala.

Expected behaviour

  • clear explanation in the docs
  • a proper warning when //> using exclude is declared wrongly
@Gedochao Gedochao added bug Something isn't working documentation Improvements or additions to documentation --exclude Issues tied with the excluding inputs. labels Dec 20, 2024
@bishabosha
Copy link
Contributor

bishabosha commented Mar 7, 2025

another example that doesn't work, if //> using exclude foo directive is in a project.scala file, but the excluded foo dir also has a project.scala

  • basically makes it impossible to have an "examples" scala-cli project (that depends on a published version of the parent) in a nested directory - you have to put the main project and examples in sibling directories
  • maybe this is less important now that test scope can have main methods invoked from command-line

@Gedochao
Copy link
Contributor Author

Gedochao commented Mar 7, 2025

another example that doesn't work, if //> using exclude foo directive is in a project.scala file, but the excluded foo dir also has a project.scala

  • basically makes it impossible to have an "examples" scala-cli project (that depends on a published version of the parent) in a nested directory - you have to put the main project and examples in sibling directories
  • maybe this is less important now that test scope can have main methods invoked from command-line

@bishabosha I am not sure I quite understand your use case. How would you suggest it should work?

@bishabosha
Copy link
Contributor

bishabosha commented Mar 7, 2025

well, i would assume exclude should tell scala-cli to never even look inside that directory. Currently (if the excluded subdirectory has project.scala) it will try to typecheck my scala code in that subdirectory - and check using directives (such as reporting unresolvable library dependencies).

I would imagine the solution being an ahead of time scan for exclude before evaluating other settings/running compiler.

if that is too complex or performance sensitive - then perhaps warn about these semantics in the documentation

@Gedochao
Copy link
Contributor Author

Gedochao commented Mar 7, 2025

Ah, now I understand.
Yup, agreed... We'd have to stop scanning for exclude as soon as it is found. Might be tricky.
I do think that's a separate issue, though.
@bishabosha can you raise it, so it doesn't get lost?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--exclude Issues tied with the excluding inputs. bug Something isn't working documentation Improvements or additions to documentation
Projects
Status: To do
Development

No branches or pull requests

2 participants