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

Conflict with pprint in mdoc in worksheet #732

Open
Tracked by #2
ckipp01 opened this issue Oct 24, 2022 · 11 comments
Open
Tracked by #2

Conflict with pprint in mdoc in worksheet #732

ckipp01 opened this issue Oct 24, 2022 · 11 comments

Comments

@ckipp01
Copy link
Member

ckipp01 commented Oct 24, 2022

Describe the bug

When working on a repo and trying something out in a worksheet I'm seeing the following error:

davidgregory084.worksheet.sc:12 (mdoc generated code) value recolor is not a member of object pprint.TPrint
val x = 3; $doc.binder(x, 2, 4, 2, 5)
                      ^                  

You can reproduce this by doing the following:

  1. Clone https://github.com/DavidGregory084/mill-tpolecat
  2. Create a worksheet next to the Scala code (I created davidgregory084.worksheet.sc via quick worksheet command, hence the weird name)
  3. Paste the following code in there:
import mill.scalalib.api.Util._

val x = 3
  1. See the error

Expected behavior

I'm assuming there is a conflict with the pprint versions in Mill vs mdoc however I don't think a user should have be hit with this. I'm not sure if the solution is shading in Mill or mdoc, but there seems to be an issue with pprint.

Operating system

macOS

Editor/Extension

Nvim (nvim-metals)

Version of Metals

0.11.9+56-6943e41c-SNAPSHOT

Extra context or search terms

value recolor is not a member of object pprint.TPrint

@tgodzik tgodzik added the bug label Oct 24, 2022
@tgodzik
Copy link
Contributor

tgodzik commented Oct 24, 2022

Thanks for reporting! I think the solution might be to inline pprint completely in mdoc or always use toString.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 30, 2022

Looking at this I think we can filter out some libraries in https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala#L424 and not include the ones used in Mdoc. This is a good candidate for the next week spree.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 27, 2022

After trying some alternatives I think the best approach is to either:

  • shade all the libraries aside from Scala
  • inline them in the codebase

@ckipp01
Copy link
Member Author

ckipp01 commented Dec 27, 2022

🤔 if it was only one I'd say maybe we can just inline it, but we then might hit on the same issues with sourceode or fansi right? In that case would it make the most sense to just shade everything com.lihaoyi in the artifacts?

@tgodzik
Copy link
Contributor

tgodzik commented Dec 28, 2022

In that case would it make the most sense to just shade everything com.lihaoyi in the artifacts?
I think so yeah.

@doofin
Copy link

doofin commented Jan 15, 2024

@tgodzik I'm also hit by this in Scala 2.13 with metals 1.2 :
image

I see there's a closed PR, so what should we do? shade everything from com.lihaoyi ?

@tgodzik
Copy link
Contributor

tgodzik commented Jan 15, 2024

Looks like it, but I will not have time to look into it.

@doofin
Copy link

doofin commented Jan 16, 2024

Is this Scala 2 specific? I checked it seems to work fine in Scala 3 @tgodzik

@tgodzik
Copy link
Contributor

tgodzik commented Jan 16, 2024

I think it's inlined already for Scala 3

@doofin
Copy link

doofin commented Jan 16, 2024

@tgodzik could you elaborate a bit? Does Scala 3 not dependent on https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala#L424 ? I see worksheetScala3Adjustments but didn't find "inline" stuff .

@tgodzik
Copy link
Contributor

tgodzik commented Jan 16, 2024

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

Successfully merging a pull request may close this issue.

3 participants