I'm working at my company on upgrading SBT from SBT 0.13.x to newest SBT and gave SBT coursier integration a try. While I had multiple issues (like differently working dependency resolution, so old conflict manager settings stopped working), the one that was most annoying was a 2 minutes lag on basically every SBT operation (on fresh SBT instance), like running a build, importing project in IntelliJ, etc I traced that lag down to invocation of powershell.exe to get two folder locations using Known Folder API inside https://github.com/soc/directories-jvm project. There seems to be no way of bypassing that check, even if I pass
What could be extremely useful would be a directories cache. E.g. if passing
PS: I don't fully know why there's such a big lag in powershell.exe invocation, but my work laptop is overloaded with powershell modules. I guess managing that would be a little painful as I would need to ask technical support to do something with it (if anything can be done). The bloatware is managed by company and I don't have full control over my OS due to security concerns (I'm working for financial company).
@tarsa Thanks! I fear this is either an issue with the local install or some general powershell/.NET issue.
@alexarchambault Before Java ships with Project Panama (improved interop with native APIs), I guess each application has to decide on its own what's the best way to deal with not being able to retrieve the standard dirs from the OS. Not sure I can offer semantics that are general enough to be useful. :-/
@tarsa Would it be possible for you to run the PowerShell command on it's own? See https://github.com/soc/directories-jvm/blob/master/src/main/java/io/github/soc/directories/Util.java#L119.
This would allow us to pinpoint the origin of the hang:
@alexarchambault Thanks for the change. I'll test it when next SBT version that integrates it comes out.
@soc I am running SBT and PowerShell through Cygwin console (that shouldn't have much impact on its own).
Running the command that directories-jvm is running takes a lot of time:
However, if I start powershell.exe from cygwin and then enter commands one by one then no lag occurs.
Judging from the timings it seems nothing CPU heavy is going on. Maybe some network resource is unavailable and powershell waits for a timeout? I tried preparing a script that would be both fast and correct, but that didn't pan out. I'm not an expert in powershell, though.
I think I nailed the reason for lag. A error message flashed once during import in IntelliJ with Coursier enabled. Message was saying that powershell was trying to load modules from network attached storage that was unreachable. I don't know why the message from powershell isn't displaying reliably.
I tried to somehow force powershell to skip loading modules when executing script block in batch mode but I have failed.