Skip to content
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

Errors with Scala 3 nightly versions #525

Closed
vincenzobaz opened this issue Jul 5, 2021 · 7 comments · Fixed by #578
Closed

Errors with Scala 3 nightly versions #525

vincenzobaz opened this issue Jul 5, 2021 · 7 comments · Fixed by #578

Comments

@vincenzobaz
Copy link

// project/plugins.sbt
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21")
// build.sbt
lazy val bugreport = project
  .in(file("."))
  .settings(
      scalaVersion := "3.0.2-RC1-bin-20210701-9f97b0b-NIGHTLY",
      mdocIn := baseDirectory.value / "site" / "docs"
      )
   .enablePlugins(MdocPlugin)

I obtain the following errors:

error: 
getting-started.md:2 (mdoc generated code) 
 package scala.compiletime does not have a member method summonFrom
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {

13

error: 
getting-started.md:2 (mdoc generated code) 
 package scala.compiletime does not have a member method erasedValue
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {

40

error: 
getting-started.md:2 (mdoc generated code) 
 package scala.compiletime does not have a member method summonFrom
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {

20

error: 
getting-started.md:3 (mdoc generated code) 
 package scala.compiletime does not have a member method erasedValue
  def app(): _root_.scala.Unit = {val _ = new App()}

94

error: 
getting-started.md:5 (mdoc generated code) 
 package scala.compiletime does not have a member method erasedValue
    $doc.startSection();

159

error: 
getting-started.md:4 (mdoc generated code) 
 package scala.compiletime does not have a member method summonFrom
  class App {

149
...
@keynmol
Copy link
Collaborator

keynmol commented Sep 21, 2021

So, my issue was slightly different but I did trace it down to some things.

Say, you have a file test.md

hello!

```scala mdoc
println("tut")
```

We can reproduce the problem above on stable Scala 3 using nothing but Coursier:

~ java -version
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)

➜  ~ java -cp $(cs fetch -p org.scalameta:mdoc_3:2.2.23) mdoc.Main --in test.md
info: Compiling 1 file to /Users/velvetbaldmime/out
error:
test.md:2 (mdoc generated code)
 package scala.compiletime does not have a member method summonFrom
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {


error:
test.md:2 (mdoc generated code)
 package scala.compiletime does not have a member method erasedValue
object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {

...

Now, I suspect these is where the issues bifurcate: the OP's issue might be down to a problem in coursier's resolution:

➜  cs resolve org.scalameta::mdoc:2.2.23 --scala-version 3 | ack 'compiler|library'
org.scala-lang:scala-compiler:2.13.6:default
org.scala-lang:scala-library:2.13.6:default

➜  cs resolve org.scalameta:mdoc_3:2.2.23 --scala-version 3 | ack 'compiler|library'
org.scala-lang:scala-compiler:2.13.6:default
org.scala-lang:scala-library:2.13.6:default
org.scala-lang:scala3-compiler_3:3.0.1:default
org.scala-lang:scala3-library_3:3.0.1:default
org.scala-sbt:compiler-interface:1.3.5:default

Notably, I think the issue above is caused by incorrectly formed classpath that is missing scala3-library

It seems that in this case mdoc is just not picking up the classpath correctly from CLI (and it's different behaviour from 2.13), and as such it can be fixed by giving it the classpath in properties:

$ mkdir test_props
$ echo "classpath=$(cs fetch -p org.scalameta:mdoc_3:2.2.23)" > test_props/mdoc.properties
$ java -cp $(cs fetch -p org.scalameta:mdoc_3:2.2.23):test_props mdoc.Main --in test.md | head
info: Compiling 1 file to /private/var/folders/my/drt5584s2w59ncgxgxpq7v040000gn/T/tmp.8rLErhj7/out
info: Compiled in 1.23s (0 errors)

So the clue here is incorrect classpath generated in the mdoc.properties

@tgodzik
Copy link
Contributor

tgodzik commented Sep 21, 2021

I can't find anything about --scala-version property, where is is coming from?

Notably, I think the issue above is caused by incorrectly formed classpath that is missing scala3-library

Not sure I understand, it seems to be present on the classpath, isin't it?

Isn't the main issue that we bring both Scala 2 and 3 compiler on the same classpath for mdoc_3 ?

@keynmol
Copy link
Collaborator

keynmol commented Sep 21, 2021

I can't find anything about --scala-version property, where is is coming from?

That would be coursier, when resolving with :: you can ask for a specific scala version, but there seems to be a bug

Not sure I understand, it seems to be present on the classpath, isin't it?

So from coursier's perspective (which is a separate bug) it's present only if you manually resolve with _3 suffix. Which might give a clue why in particular nightlies don't work in SBT (coursier can't infer suffix?)

On the other hand, only adding the full classpath to mdoc.properties resolves the issue.

I don't think the 2 compilers stuff actually affects it - IIRC this is due to Scalameta being on 2.13 only, and it sort of worked this way since we added the support for Scala 3 to mdoc.

@keynmol
Copy link
Collaborator

keynmol commented Oct 18, 2021

I think this happened again, but for stable 3.1.0 in https://github.com/typelevel/cats-effect/pull/2428/checks?check_run_id=3927359459#step:10:22

@dos65
Copy link
Member

dos65 commented Oct 21, 2021

@vincenzobaz could you try the latest mdoc release?

I think this one should be fixed by #568

@vincenzobaz
Copy link
Author

@dos65 I can still produce the error with this config.
The error is there even if I upgrade to scala 3.1.0.
The error does not occur when I use 3.0.2

@keynmol
Copy link
Collaborator

keynmol commented Oct 28, 2021

@vincenzobaz before we release new mdoc, can you test with the following snapshot: 2.2.24+10-1c1cc9bb-SNAPSHOT (you'll need snapshot resolvers in both project/plugins.sbt and build.sbt)

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 a pull request may close this issue.

4 participants