14

After having installed sbt version 0.13.13 (with brew) on Mac 10.12.2 with scala 2.12.0, I tried the first example on the documentation (as per subject sbt new sbt/scala-seed.g8).

The result is:

...
[info] Set current project to hello (in build file:/scratch/hello/)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.eclipse.jgit.api.errors.TransportException: http://github.com/sbt/scala-seed.g8.git: 301 Moved Permanently
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139)
...

I'm absolutely new on sbt, just wondering if this is an issue due to my inexperience...

streetturtle
  • 5,472
  • 2
  • 25
  • 43
Mario Alemi
  • 1,797
  • 1
  • 13
  • 18
  • You can ignore the slf4j warning but the error seems to indicate a network problem? Are you connected to the internet? Are you working with a proxy? – evan.oman Jan 04 '17 at 15:17
  • 1
    yes, I am connected to the internet, no proxy, and the machine can access the URL http://github.com/sbt/scala-seed.g8.git – Mario Alemi Jan 04 '17 at 17:20
  • The URL provided redirects to a secure connection (`https`) and it looks like the `jgit` client isn't handling this correctly. This looks a lot like a bug in the git client. – jkinkead Jan 05 '17 at 00:58
  • @jkinkead not sure, unless `jgit` is different from `git`. I've tested `git`, and can clone repositories from the http URL without problem – Mario Alemi Jan 08 '17 at 10:44
  • I'm seeing the same issue on ubuntu 14.04 with git version 1.9.1 – arnfred Feb 26 '17 at 21:08

6 Answers6

27

I had the same issue. Even if you can access http://github.com/sbt/scala-seed.g8.git , your git 9418 port may still be blocked when using sbt or g8. Try running the line below at the command line. It will switch the port that git uses to https:// which is usually not blocked.

git config --global url."https://".insteadOf git://

It simply adds the following lines to your .gitconfig

[url "https://"]
    insteadOf = git://

so you can easily remove it if that is not the issue.

Sully
  • 494
  • 1
  • 5
  • 12
  • Thanks but nope, port is not blocked and changing the port with your suggestion does not help... – Mario Alemi Mar 09 '17 at 13:27
  • I meet the same error, this method works for me, thanks : ) – Little Roys Aug 15 '17 at 01:22
  • Yup, I am trying the HelloWorld for sbt-0.13 (https://www.scala-sbt.org/0.13/docs/Hello.html) and ran into the same problem asked in the original Question. This solution worked fine. Initially I thought it was sbt not able to pull in correct ssh key because I got a slightly strange error - ``` org.eclipse.jgit.api.errors.TransportException: git@github.com:sbt/scala-seed.g8.git: invalid privatekey: [B@578c3fd9org.eclipse.jgit.api.errors.TransportException: git@github.com:sbt/scala-seed.g8.git: invalid privatekey: [B@578c3fd9 ``` But @Sully's answer worked like magic. – ARK May 30 '21 at 21:20
15

Run it passing as a parameter the git url:

sbt new https://github.com/sbt/scala-seed.g8

There is no need of changing any git configuration.

dsantaolalla
  • 441
  • 4
  • 6
4

git clone http://github.com/scala/hello-world.g8.git

mv ./hello-world.g8/src/main/g8 hello-world

cd hello-world

sbt run

(assuming you have git setup)

lawazoni
  • 55
  • 5
vamsi vegi
  • 106
  • 5
1

Try using

sbt new scala/scala-seed.g8

A predefined template in git is required, but when you use one of the sample templates from git, it will create an sbt project with minimum scala build. And to name the project, the predefined templates usually provide you with an option to do so.

Arjun
  • 19
  • 3
1

I would like to share my experience:

I wanted to run sbt new scalatra/scalatra.g8 and was facing error

"git@github.com:scalatra/scalatra.g8.git: invalid privatekey: [...."

How fixed it ?

mkdir temp 
cd temp
git clone https://github.com/foundweekends/giter8.g8
g8 file://giter8.g8

Now it's working and printing

Creates a Giter8 project template. 

name [My Template Project]:

Hopefully it will save someone's time.

R Sun
  • 1,353
  • 14
  • 17
0

I've experienced similar problem. The way I solved is by installing sdkman:

curl -s "https://get.sdkman.io" | bash 

Then, instead of my system package manager, I use sdkman to install the scala stuff:

sdk install java
sdk install sbt
sdk install scala

After that, the examples from the documentation works fine in my machine.

Tino
  • 394
  • 4
  • 7