1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

sbtコマンド実行時のinsecure HTTP request is unsupportedエラーを解決する方法

Posted at

sbtコマンド実行時のinsecure HTTP request is unsupportedエラーを解決する方法

久しぶりにsbtを使ってみたら、見事爆死しました。
sbtとAdoptOpenJDKをアップデートしたけど解決しませんでした。

発生したエラー

$ sbt new scala/scala-seed.g8
copying runtime jar...
[info] welcome to sbt 1.4.6 (AdoptOpenJDK Java 11.0.9.1)
[info] loading settings for project global-plugins from idea.sbt ...
[info] loading global plugins from /Users/kuratadaisuke/.sbt/1.0/plugins
[info] set current project to projects (in build file:/Users/kuratadaisuke/Projects/)
[info] set current project to projects (in build file:/Users/kuratadaisuke/Projects/)
[error] insecure HTTP request is unsupported 'http://repo.artima.com/releases'; switch to HTTPS or opt-in as ("Artima Maven Repository" at "http://repo.artima.com/releases").withAllowInsecureProtocol(true), or by using allowInsecureProtocol in repositories file
[error] java.lang.RuntimeException: insecure protocol is unsupported
[error] 	at scala.sys.package$.error(package.scala:30)
[error] 	at sbt.Classpaths$.errorInsecureProtocol(Defaults.scala:3117)
[error] 	at sbt.Classpaths$.$anonfun$mkIvyConfiguration$1(Defaults.scala:3713)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:834)
[error] (ivyConfiguration) insecure protocol is unsupported

原因

insecure HTTP request is unsupported 'http://repo.artima.com/releases'

HTTPリクエストでArtima Maven Repositoryにアクセスしていることが原因です。
Spring Plugins RepositoryでもHTTPリクエストを送信したら400か401かのエラーが発生していたが同じだろうか。

実際に~/.sbt/1.0/global.sbtを開くと、Artima Maven RepositoryのURLがHTTPプロトコルで定義されていた。

global.sbt
resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases"

解決策1

("Artima Maven Repository" at "http://repo.artima.com/releases").withAllowInsecureProtocol(true)

ここに書いてある通りに~/.sbt/1.0/global.sbtを修正します。

global.sbt
// resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases"
resolvers += ("Artima Maven Repository" at "http://repo.artima.com/releases").withAllowInsecureProtocol(true)

sbt new scala/scala-seed.g8を実行したら動きました。

解決策2

解決策1を実施してから思いましたが、URLをHTTPSにすれば良いだけのような気がしました。

global.sbt
// resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases"
resolvers += "Artima Maven Repository" at "https://repo.artima.com/releases"

sbt new scala/scala-seed.g8を実行したら動きました。

まとめ

最近HTTPリクエストを受け付けなくなったリポジトリがいくつかあるのかもしれない。どこかのリポジトリからライブラリがダウンロードできなくなったら、同様の対応をすれば直ると思います。(思うだけ)

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?