-
Notifications
You must be signed in to change notification settings - Fork 281
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
[Bug] Scalafmt::format
fails to download scalafmt artifacts
#2793
Comments
Scalafmt::format
fails to download itselfScalafmt::format
fails to download itself
Scalafmt::format
fails to download itselfScalafmt::format
fails to download scalafmt artifacts
Thanks for reporting! This looks like an issue with coursier though, maybe it's an older version of coursier in What is weird is that we actually run tests that download scalafmt in Metals and I have never seen them fail. Maybe it's an issue with github runners? Did this happen only recently? Anyway, this doesn't look like something that we can fix in scalafmt 🤔 |
Yes, I did. Initially, I was using v3.0.x in my "POC project" and was having the same issue. I moved to 2.7.5 because I thought the bug was coming from v3 but in fact, it happens in both.
Caliban is not using Github Actions. It's using CircleCI and IIRC, we also had this issue in CircleCI. To validate this point I just created 2 draft PRs in Caliban to try to reproduce the issue in CircleCI.
Corresponding CircleCI runs:
I started to work on this sbt plugin maybe 1 or 2 months ago. Can you maybe point me where is the code in charge of interacting with Coursier in Scalafmt, so I can have a look? Edit: Interestingly, on the 2 CircleCI runs, one failed and one passed 😄 |
Could it bee that it's being run in parallel? I found an issue in coursier coursier/coursier#1815 |
Maybe, but in theory, seeing the code here: #2793 (comment), it should be sequential (all the code is run in one "blocking" task), except if it's Coursier or Scalafmt that are parallelizing the calls. But for sure, there's something around that. The non-deterministic nature of this bug clearly points towards this IMO. |
Maybe it's the case that you are trying to load Scalafmt multiple times? So if you are running |
Based on solution proposed here: coursier/coursier#2022 (comment)
Well, based on this potential solution to my problem: coursier/coursier#2022 (comment), I implemented an "ugly fix" in Caliban: ghostdogpr/caliban#1072 and rebased my 2 draft PRs on top of this "ugly fix" to relaunch the 2 CircleCI runs: |
Ok. It works and I understand why I have this issue. I am indeed running multiple instances of Coursier in parallel because I'm generating, in this test, something like 4 different Caliban clients in paralleled so when the code is generated, the calls the So I'm effectively experiencing the race condition that you mentioned (coursier/coursier#1815) Thanks for your help 🙏 |
Fixed in #3530. |
Hi 🙂,
In Caliban (https://github.com/ghostdogpr/caliban), we generate some code and then we
scalafmt
it thanks to this piece of code:(Comes from: https://github.com/ghostdogpr/caliban/blob/master/tools/src/main/scala/caliban/tools/Formatter.scala)
This piece of code, most of the time, fails if scalafmt hasn't been already downloaded on the computer executing it, with errors like this one:
In this execution, it failed to download
scopt_2.13-3.7.1.jar
but it's not always this lib that fails.It's pretty much non-deterministic. Sometimes it works, sometimes it fails.
You can observe this behaviour in these Github Actions: https://github.com/guizmaii/poc_compile_time_caliban_client_generation/actions
This repo contains a project I use to develop a new sbt plugin for Caliban that generates Caliban client code at compile time from the Caliban server code: when you configure this plugin and then compile your project, the Caliban client code will be generated (and formatted with Scalafmt if necessary/configured). But because of this bug, the execution of my sbt plugin task fails. 😕
Here's an example of a run that failed because of that bug: https://github.com/guizmaii/poc_compile_time_caliban_client_generation/runs/3835687661?check_suite_focus=true
And here's one that worked: https://github.com/guizmaii/poc_compile_time_caliban_client_generation/runs/3754046726?check_suite_focus=true
The text was updated successfully, but these errors were encountered: