David Boulton
David Boulton

Reputation: 183

"Insecure HTTP request is unsupported" Error in Scala

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.

Upvotes: 16

Views: 14002

Answers (4)

Henry
Henry

Reputation: 3328

Had to edit ~/.sbt/repositories to use https.

Upvotes: 1

Alex
Alex

Reputation: 61

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.

Upvotes: 6

Shinoy Sam
Shinoy Sam

Reputation: 236

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.

Upvotes: 22

Tomer Shetah
Tomer Shetah

Reputation: 8539

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.

Upvotes: 4

Related Questions