Dependency / root / ivy problems in Sbt / Mill


#1

Ok I’ve started this thread for myself and Elyphas as we were getting errors like

[error] sbt.librarymanagement.ResolveException: unresolved dependency: org.scala-js#sbt-scalajs;0.6.22: Resolution failed several times for dependency: org.scala-js#sbt-scalajs;0.6.22 {compile=[default(compile)]}:: 
[error]         typesafe-ivy-releases: unable to get resource for org.scala-js#sbt-scalajs;0.6.22: res=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-js/sbt-scalajs/scala_2.12/sbt_1.0/0.6.22/ivys/ivy.xml: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
[error]         sbt-plugin-releases: unable to get resource for org.scala-js#sbt-scalajs;0.6.22: res=https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scala-js/sbt-scalajs/scala_2.12/sbt_1.0/0.6.22/ivys/ivy.xml: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

or errors that mention “/root/.ivy2/…”

Thanks to Otto Chrons for his suggestion:

"at the risk of stating the obvious, I think the following might have happened:

You've launched SBT in your project as root somehow.
It downloaded a dependency to ~/.ivy2/..., which for root resolved to /root/.ivy2/..., with root as an owner.
It also cached the resulting reference.
Now, if you run without sudo, you can't access the referenced file.
This can be worked around using chown/chmod, but a cleaner solution would be to just nuke all the target/ folders in your project. Something along the lines of

sudo find path/to/project -name target -type d -delete

Don’t forget to run

sudo find path/to/project -name target -type d -print

beforehand to make sure you don’t remove something important."

So we probably both just messed up and called sbt as root. In my case I must have messed up twice and called mill as root as well. So hopefully if, or rather when, someone else makes this mistake in the future, they will be able to find this thread. However it is just possible that, we didn’t mess up and the fault lies within the Ubuntu 18.04 core.

So I’ve checked my projectName/project/target/scala-2.12/sbt-1.0/classes/ folder and found that I do indeed have files with root ownership.


#2

So I had to apply the following commands:

sudo dpkg --purge --force-depends ca-certificates-java
sudo apt install ca-certificates-java
sudo update-alternatives --config java
sudo update-alternatives --all

It wasn’t sufficient just to get rid of the root owned files.