JetBrains / kotlin-native

Kotlin/Native infrastructure
Apache License 2.0
7.02k stars 564 forks source link

Retrieving package behind authenticated proxy fails 407 #4713

Closed cleanerx closed 3 years ago

cleanerx commented 3 years ago

Hi,

I get this with kotlin multiplatform 1.4.10 compiling to native

org.jetbrains.kotlin.konan.util.DependencyDownloader$HTTPResponseException: Server returned HTTP response code: 407 for URL: https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz at org.jetbrains.kotlin.konan.util.DependencyDownloader.checkHTTPResponse(DependencyDownloader.kt:67) at org.jetbrains.kotlin.konan.util.DependencyDownloader.tryDownload(DependencyDownloader.kt:144) at org.jetbrains.kotlin.konan.util.DependencyDownloader.download(DependencyDownloader.kt:180) at org.jetbrains.kotlin.konan.util.DependencyDownloader.download$default(DependencyDownloader.kt:158) at org.jetbrains.kotlin.konan.util.DependencyProcessor.downloadDependency(DependencyProcessor.kt:203) at org.jetbrains.kotlin.konan.util.DependencyProcessor.run(DependencyProcessor.kt:283) at org.jetbrains.kotlin.konan.properties.KonanPropertiesLoader.downloadDependencies(KonanProperties.kt:44) at org.jetbrains.kotlin.konan.target.Platform.downloadDependencies(Platform.kt) at org.jetbrains.kotlin.backend.konan.KonanConfig.(KonanConfig.kt:60) at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:64) at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:35) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45) at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227) at org.jetbrains.kotlin.cli.bc.K2Native$Companion$mainNoExitWithGradleRenderer$1.invoke(K2Native.kt:276) at org.jetbrains.kotlin.cli.bc.K2Native$Companion$mainNoExitWithGradleRenderer$1.invoke(K2Native.kt:260) at org.jetbrains.kotlin.util.UtilKt.profileIf(Util.kt:27) at org.jetbrains.kotlin.util.UtilKt.profile(Util.kt:21) at org.jetbrains.kotlin.cli.bc.K2Native$Companion.mainNoExitWithGradleRenderer(K2Native.kt:275) at org.jetbrains.kotlin.cli.bc.K2NativeKt.mainNoExitWithGradleRenderer(K2Native.kt:427) at org.jetbrains.kotlin.cli.utilities.MainKt$daemonMain$1.invoke(main.kt:39) at org.jetbrains.kotlin.cli.utilities.MainKt$daemonMain$1.invoke(main.kt) at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:17) at org.jetbrains.kotlin.cli.utilities.MainKt.daemonMain(main.kt:39) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.jetbrains.kotlin.compilerRunner.KotlinToolRunner.runInProcess(KotlinToolRunner.kt:98) at org.jetbrains.kotlin.compilerRunner.KotlinToolRunner.run(KotlinToolRunner.kt:71) at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinNativeCompile.compile(KotlinNativeTasks.kt:310) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:570) at

SvyatoslavScherbina commented 3 years ago

Hi.

org.jetbrains.kotlin.konan.util.DependencyDownloader$HTTPResponseException: Server returned HTTP response code: 407 for URL: https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz

Looks like a local problem on your side. 407 is "Proxy Authentication Required". Do you use any proxy that requires authentication? Does the link work from your browser? I can download this file just fine.

Also, I'm just curious: how did you create this issue? "New issue" button for kotlin-native repository on GitHub web site doesn't allow to create one (and this is intentional). So did you use a custom GitHub client or whatever?

cleanerx commented 3 years ago

The problem is for sure on my side since I'm frequently confronted with our proxy and subsequent problems :-) However setting the properties 'somewhere' is usually the resolution. I think the problem here is that neither IDEA in which I started the project nor gradle https proxy settings where honored since it is a standalone solution. Depending on the java library used for http different methods exist for setting the proxy. If the java standard libary is being used I will have problems since it does not allow to set the proxy password and username since a standalone implementation is used. So where exactly do I need to set proxy settings in order to retrieve the file properly.

Note: I used new issue from standard github.

SvyatoslavScherbina commented 3 years ago

I will provide the details and maybe a workaround later.

Note: I used new issue from standard github.

What do you mean by "standard github"? Is it the github.com website, or some standard app? For the website, if I press "New issue" button on the issues page, the following page opens: https://github.com/JetBrains/kotlin-native/issues/new/choose It doesn't seem to have an option to create new issue on GitHub on my side.

So, where do you use "new issue" and which URL does it navigate you to?

cleanerx commented 3 years ago

The issue was posted through the web page. But I'm not sure about the entry point. There was another issue which was closed where someone posted the same 407 but unrelated to the original issue. I must have been starting from there. Looking right now I'm also being presented to the triple choice you presumably suggest.

SvyatoslavScherbina commented 3 years ago

The compiler uses standard Java's URL.openConnection. I'm not sure that one can easily configure it to use an authenticated proxy without patching the compiler.

As the last option, please try the following:

  1. Download the archive manually
  2. Unpack it into ~/.konan/dependencies
  3. Add its name to ~/.konan/dependencies/.extracted.

The same should probably be done for other similar dependencies, should be around 4 of them if you use only one target. Anyway, this workaround can easily be automated with a script. Does this work for you?

Submitting an issue to YouTrack also makes sense: https://kotl.in/issue.

cleanerx commented 3 years ago

Usually for standard Java an Authenticator must be provided like here: https://stackoverflow.com/questions/1626549/authenticated-http-proxy-with-java

I'll check the suggested solution.

cleanerx commented 3 years ago

This worked around the proxy problem. I opened another issue because a library is missing so I couldn't get it to compile.