intellij-dlanguage icon indicating copy to clipboard operation
intellij-dlanguage copied to clipboard

ProcessDLibs cannot handle sub packages

Open andre2007 opened this issue 7 years ago • 5 comments

dub.json contains sub package specification:

"dependencies" : {
 "arsd-official:cgi" : "2.1.0"
 }

During action ProcessDLibs this cause the error:

java.lang.Throwable: error while fetching:Package arsd-official:cgi not found for registry at https://code.dlang.org/ (fallback ["registry at http://code.dlang.org/", "registry at https://code-mirror.dlang.io/", "registry at https://code-mirror2.dlang.io/", "registry at https://dub-registry.herokuapp.com/"]): (1): Error: Got JSON of type null_, expected object.

	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:123)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.getSourcesVirtualFile(ProcessDLibs.kt:268)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.createLibraryDependency(ProcessDLibs.kt:181)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.processDLibsImpl(ProcessDLibs.kt:139)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.access$processDLibsImpl(ProcessDLibs.kt:76)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion$processDLibs$1$task$1.run(ProcessDLibs.kt:92)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
	at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

andre2007 avatar Sep 14 '18 11:09 andre2007

isn't this just that it couldn't connect to the repository at the time? ProcessDLibs just runs dub describe and parses the output json. I've not debugged it with the plugin yet but running dub describe locally gave my local path for arsd-official:cgi as:

C:\Users\singingbush\AppData\Roaming\dub\packages\arsd-official-2.1.0\arsd-official\

SingingBush avatar Sep 17 '18 12:09 SingingBush

The issue is, dub fetch doesn't support the format packageName:subPackageName This fails: dub fetch arsd-official:cgi

dub fetch is called here https://github.com/intellij-dlanguage/intellij-dlanguage/blob/develop/src/main/kotlin/io/github/intellij/dlanguage/actions/ProcessDLibs.kt#L237

Proposed bugfix: in case dubPackage.name contains a sub package, only the parent package is passed to dub fetch.

I will also check whether dub fetch can be enhanced, but that is nothing the IntelliJ plugin can rely on.

andre2007 avatar Sep 17 '18 14:09 andre2007

Also this issue is caused by the calling dub fetch wrongly

java.lang.Throwable: error while fetching:Trying to append absolute path.

	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:123)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.getSourcesVirtualFile(ProcessDLibs.kt:268)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.createLibraryDependency(ProcessDLibs.kt:181)
	at io.github.intellij.dlanguage.actions.ProcessDLibs$Companion.processDLibsImpl(ProcessDLibs.kt:139)

The error is shown while opening my project containing sub-packages in dependencies.

andre2007 avatar Sep 19 '18 06:09 andre2007

In general s.th. like

val colonIndex = dubPackage.name.indexOf(":")
				if (colonIndex > -1) {
					parametersList.addParametersString(dubPackage.name.substring(0, colonIndex))
				} else {
					parametersList.addParametersString(dubPackage.name)
				}

in method getSourcesVirtualFile should be sufficient to solve the issue.

Unfortunately package arsd-official is a special case, The sub packages do not have the "importPaths" attribute in dub.json and also a folder source is missing. Therefore this logic fails

val srcDir = if(dubPackage.sourcesDirs.isNotEmpty()) {
                if(dubPackage.sourcesDirs.size > 1) {
                    LOG.warn("it's likely that we're not processing ${dubPackage.name} correctly. ${dubPackage.sourcesDirs.size} source folders found")
                }
                dubPackage.sourcesDirs[0]
            } else "source"

andre2007 avatar Sep 21 '18 10:09 andre2007

Sentry report for this:

java.lang.Throwable: error while fetching:Package ann_exec:testsuite not found for registry at https://code.dlang.org/ (fallbacks registry at https://code-mirror.dlang.io/, registry at https://dub-registry.herokuapp.com/): (1): Error: Got JSON of type null_, expected object.

	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:146)
	at io.github.intellij.dlanguage.actions.ProcessDLi...

last action was ShowSettings

SingingBush avatar Jul 27 '20 07:07 SingingBush