Closed PawanKartikS closed 1 year ago
Hey, @PawanKartikS thank you for reporting! I tried to reproduce it with, for example
COURSIER_REPOSITORIES="jitpack" ./scalafmt --debug
but scalafmt correctly try to resolve from jitpack
, and failed (because there's no binary on jitpack) then fallback to sonatype
which is a default repository set by scalafmt.
Which repository did you specify by COURSIER_REPOSITORIES
?
I just specified 1 repository, our Nexus endpoint.
Can you download the scalafmt binary from the Nexus repository?
scalafmt-cli does indeed support COURSIER_REPOSITORIES
.
./cs bootstrap org.scalameta:scalafmt-cli_2.13:3.5.9 --verbose --standalone -o /some_path/scalafmt
This command pulls 3.5.9 from Nexus. Is this what you're asking?
Hmm, then I have no idea what's going on in your environment 🤔
I have an update for you. I'm not sure how relevant it is but I thought I should point it out. When scalafmt is invoked, it very briefly, for a sec, hits our Nexus repo and then switches back to oss.sonatype.org. It happens so quickly that it was nearly impossible to notice. I had to record my screen and move frame by frame to notice this happen. Are there any scenarios where the scalafmt would switch the repo it is using without facing any error?
That happens if the binary is not found in the repository (that's why I asked "Can you download the scalafmt binary from the Nexus repository?")
Can you find org.scalameta:scalafmt-core_2.13:3.5.9
from your nexus repository instead of scalafmt-cli
(I guess you can though...)
Yes, I just pulled in org.scalameta:scalafmt-core_2.13:3.5.9
successfully and I can confirm that I was able to view it from within our repo manager. I even was able to pull a few other versions.
Our environment does not support egress so we use Nexus repository manager. While we are able to use coursier to fetch what we want by specifying
COURSIER_REPOSITORIES
ANDCOURSIER_CREDENTIALS
,scalafmt
seems to hitoss.sonatype.org
while resolving the version specified in the.scalafmt.conf
file. If the former env variable isn't set, it straight away goes to maven. Am I correct in assuming thatscalafmt
supportsCOURSIER_REPOSITORIES
, ref? If it does indeed support it, shouldn't it hit our Nexus instead?Version: 3.5.9
Additional helpful information: I've tried running
coursier
to fetch something which hit our Nexus and was successful. The next immediate command that I ran wasscalafmt
asscalafmt Foo.scala --debug
which hit some other endpoint/host instead of our Nexus. And because the egress is blocked, it simply sat there with the progress bar at 0%. I've double checked that the env variables are correct. Coursier being able to pull what I've asked for also shows that the configuration is correct.Configuration
Command-line parameters
scalafmt Main.scala --debug
Expectation
I'd expect that
scalafmt
format the code as per its functionality.