foundweekends / foundweekends/giter8
NPE when running `sbt new` in MingW console on Windows
- Dominant language
- Scala
- Stars
- 1.8k
- Forks
- 225
- Avg merge
- 2h 35m
- Merged PRs (30d)
- 8
Description
Originally reported by @frankschmitt as https://github.com/sbt/sbt/issues/3567
## steps
- open a Mingw64 console (e.g. from a "Git for Windows" installation)
- create a new empty dir, cd into it and try to create a new application:
```
mkdir sbt_bug
cd sbt_but
sbt new scala/scala-seed.g8
```
## problem
```
$ sbt new scala/scala-seed.g8
[info] Set current project to sbt_bug (in build file:/C:/Users/schmitt/Desktop/workdir/sbt_bug/)
[error] java.lang.NullPointerException
[error] at giter8.ConsoleCredentialsProvider$.askYesNo(JgitHelper.scala:179)
[error] at giter8.ConsoleCredentialsProvider$.$anonfun$get$1(JgitHelper.scala:169)
[error] at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
[error] at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
[error] at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
[error] at giter8.ConsoleCredentialsProvider$.get(JgitHelper.scala:156)
[error] at giter8.ConsoleCredentialsProvider$.get(JgitHelper.scala:149)
[error] at org.eclipse.jgit.transport.CredentialsProviderUserInfo.promptYesNo(CredentialsProviderUserInfo.java:124)
[error] at com.jcraft.jsch.Session.checkHost(Session.java:736)
[error] at com.jcraft.jsch.Session.connect(Session.java:319)
[error] at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
[error] at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)
[error] at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:262)
[error] at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161)
[error] at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
[error] at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
[error] at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1138)
[error] at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
[error] at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:193)
[error] at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:133)
[error] at giter8.JgitHelper$.clone(JgitHelper.scala:116)
[error] at giter8.JgitHelper$.run(JgitHelper.scala:67)
[error] at giter8.Giter8.$anonfun$run$2(giter8.scala:34)
[error] at scala.Option.map(Option.scala:146)
[error] at giter8.Giter8.run(giter8.scala:33)
[error] at sbtgiter8resolver.Giter8TemplateResolver.run(Giter8TemplateResolver.scala:31)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[error] at java.lang.reflect.Method.invoke(Unknown Source)
[error] at sbt.TemplateCommandUtil$.call(TemplateCommand.scala:93)
[error] at sbt.TemplateCommandUtil$.runTemplate(TemplateCommand.scala:71)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1(TemplateCommand.scala:51)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1$adapted(TemplateCommand.scala:47)
[error] at scala.collection.LinearSeqOptimized.find(LinearSeqOptimized.scala:111)
[error] at scala.collection.LinearSeqOptimized.find$(LinearSeqOptimized.scala:108)
[error] at scala.collection.immutable.List.find(List.scala:86)
[error] at sbt.TemplateCommandUtil$.run(TemplateCommand.scala:47)
[error] at sbt.TemplateCommandUtil$.runTemplate(TemplateCommand.scala:34)
[error] at sbt.TemplateCommandUtil$.$anonfun$templateCommand$2(TemplateCommand.scala:17)
[error] at sbt.Command$.$anonfun$applyEffect$4(Command.scala:125)
[error] at sbt.Command$.$anonfun$applyEffect$2(Command.scala:121)
[error] at sbt.MainLoop$.processCommand(MainLoop.scala:121)
[error] at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:105)
[error] at sbt.State$$anon$1.runCmd$1(State.scala:227)
[error] at sbt.State$$anon$1.process(State.scala:233)
[error] at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:105)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.MainLoop$.next(MainLoop.scala:105)
[error] at sbt.MainLoop$.run(MainLoop.scala:98)
[error] at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:76)
[error] at sbt.io.Using.apply(Using.scala:22)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:70)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:52)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:37)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:29)
[error] at sbt.StandardMain$.runManaged(Main.scala:104)
[error] at sbt.xMain.run(Main.scala:71)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.NullPointerException
[error] Use 'last' for the full log.
```
## expectation
A new project should be created
## notes
Presumably, the root cause is that sbt tries to ask for confirmation because it cannot identify Github and fails since it cannot identify the MingW console. For comparison, this is what I get when I run it from CMD instead:
```
C:\Users\schmitt\Desktop\workdir\sbt_bug>sbt new scala/scala-seed.g8
"C:\Users\schmitt\.sbt\preloaded\org.scala-sbt\sbt\"1.0.2"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Set current project to sbt_bug (in build file:/C:/Users/schmitt/Desktop/workdir/sbt_bug/)
The authenticity of host 'github.com' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting?:
```
sbt version: *1.0.2*
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce `sbt new scala/scala-seed.g8` from a Mingw64 console and compare it with the CMD behavior. Start at `JgitHelper.scala:179`, where the stack trace shows the NPE during the host-confirmation prompt, then trace the call through `giter8.scala`. Done means the template command no longer fails with an NPE and a new project is created.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github, scala
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100