Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
745 views
in Technique[技术] by (71.8m points)

scala - SBT 0.13.11 cannot download dependencies behind a proxy

Using Windows 7, 64bit, behind a proxy server.

I have downloaded and installed the latest versions of SBT(0.13.11), Scala(2.11.8), and IntelliJ IDEA Community(2016.1.2). When I try to start a new project in IntelliJ, the newest version of SBT I can use is 0.13.8, not 0.13.11. Does anyone know why this might be? If I try to start a new project I get an error:

Error:Error while importing SBT project:
...

[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang#scala-library;2.11.8: not found
[warn]  :: org.scala-lang#scala-compiler;2.11.8: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      org.scala-lang:scala-library:2.11.8 ((sbt.Classpaths) Defaults.scala#L1203)
[warn]        +- default:untitled1_2.11:1.0
[warn]      org.scala-lang:scala-compiler:2.11.8
[warn]        +- default:untitled1_2.11:1.0
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[trace] Stack trace suppressed: run 'last :ssExtractDependencies' for the full output.
[error] (:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.11.8: not found
[error] unresolved dependency: org.scala-lang#scala-compiler;2.11.8: not found
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.11.8: not found
[error] unresolved dependency: org.scala-lang#scala-compiler;2.11.8: not found
[error] Total time: 4 s, completed May 25, 2016 10:51:00 AM
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

See complete log in C:UsersRk.IdeaIC2016systemlogsbt.last.log

After tinkering for a while, I discovered that when I type sbt about at the terminal, I am told that I have SBT version 0.13.8, which is built against Scala 2.10.4. That doesn't look right! If I go into IntelliJ and choose the SBT build as 0.13.8 and Scala build as 2.10.4, I get no error!!

So, this is pretty confusing because it's not clear whether the proxy is the issue or not. It seems like if I could just update SBT to version 0.13.11 the whole thing would work.

Any insight or help would be greatly appreciated - I am excited to learn Scala but these technical difficulties are stopping me.

EDIT: When I run sbt compile in the project directory, I receive the following output: enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There's one red line your sbt's output:

[error] Server access Error: Connection refused: connect url=https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.pom

It happens because you're behind a proxy, and starting with version 0.13.9, sbt by default uses https for all connections. sbt 0.13.8 still uses http, that's why this problem doesn't manifest in this version.

The easiest way to cope with this problem is to modify your sbt.bat script and add an argument to the command line which launches sbt executable:

-Dsbt.repository.secure=false

This command forces sbt to use http instead.

A seemingly more correct, but much more complex way to fix involves manual extraction of https certificates from maven repositories you use and their installation into your JDK's cacerts keystore using keytool - however this complex way doesn't seem to cover all cases, while turning https off completely works like a charm.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...