“Insecure HTTP request is unsupported” Error in Scala

不打扰是莪最后的温柔 提交于 2021-01-05 08:56:55

问题


I am getting the following error when attempting to run sbt run to run my Scala code:

insecure HTTP request is unsupported 'http://repo.typesafe.com/typesafe/releases'; switch to HTTPS or opt-in as ("typesafe-releases" at "http://repo.typesafe.com/typesafe/releases").withAllowInsecureProtocol(true), or by using allowInsecureProtocol in repositories file

This is strange because it was working perfectly fine last week and I have changed nothing in the code. I have tried adding ("typesafe-releases" at "http://repo.typesafe.com/typesafe/releases").withAllowInsecureProtocol(true) in my build.sbt file and resolver file, installing Java11, deleting my project folder, and completely reclone my code from the repository but nothing is working. I am using Visual Studios but have also tried on IntelliJ and get the same error.

Any advice would be greatly appreciated, as I have changed nothing and now suddenly my code doesn't compile anymore. Further details:

sbt.version = 1.4.0

Scala code runner version 2.12.10

My current built.sbt (please note that I did not have the resolve part added before, when my code was working fine. It was added as an attempt to resolve the issue but did not work):

scalaVersion := "2.12.10"

name := "name"
organization := "org"
version := "1.0"

libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
"org.apache.spark" %% "spark-core" % "3.0.1",
"org.apache.spark" %% "spark-sql" % "3.0.1",
"org.reactivemongo" %% "reactivemongo-bson-api" % "0.20.11",
"org.mongodb.spark" %% "mongo-spark-connector" % "3.0.0",
"com.ibm.db2.jcc" % "db2jcc" % "db2jcc4"
)

resolvers += Resolver.typesafeRepo("releases")

EDIT: I've discovered that this error occurs regardless of project, and even occurs when I simply run sbt by itself.


回答1:


Did you try deleting ~/.sbt folder? I had a repositories file in this folder that had HTTP references to the typesafe repo and deleting this folder resolved those sbt HTTP errors.




回答2:


For anyone else using an Intellij setup with this issue, see below

Environment:

  • Scala 2.12.7
  • Intellij Ultimate
  • JVM 11

The issue seems to be a clash between the Intellij IDE SBT plugin ( still on 1.3.2 ) and what seems to be a silent update of sbt.

Running sbt ( version 1.4.3 ) in a terminal instead of using the built in plugin fixed the issue.




回答3:


As mentioned in repo.typesafe.com, you can add to your sbt:

Resolver.typesafeIvyRepo("releases")

or:

Resolver.typesafeRepo("releases")

Depends whether you are using Ivy or not.

The reason to this warning is the fact that you are using http and not https. From sbt 1.4.0 release notes:

HTTP resolvers require explicit opt-in using .withAllowInsecureProtocol(true)

This is the PR that added it.



来源:https://stackoverflow.com/questions/64989130/insecure-http-request-is-unsupported-error-in-scala

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!