Gatsby: Make gatsby new clone using https instead of ssh

Created on 3 Jan 2018  Â·  5Comments  Â·  Source: gatsbyjs/gatsby

Description

When initiating a project with the gastby new command, the project could be cloned with https, as in some environments/companies cloning using git/ssh is not supported.

Environment

Gatsby version: 1.1.28
Node.js version: v8.9.1
Operating System: Windows 7 SP1

Actual result

$ gatsby new gatsby-site
info Creating new site from git: git://github.com/gatsbyjs/gatsby-starter-default.git
Cloning into 'gatsby-site'...
fatal: Unable to look up github.com (port 9418) (Unknown host)
error Command failed: git clone git://github.com/gatsbyjs/gatsby-starter-default.git gatsby-site --single-branch


  Error: Command failed: git clone git://github.com/gatsbyjs/gatsby-starter-defa  ult.git gatsby-site --single-branch

  - index.js:236 Promise.all.then.arr
    [global]/[gatsby-cli]/[execa]/index.js:236:11

  - util.js:16 tryCatcher
    [global]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [global]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [global]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [global]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [global]/[bluebird]/js/release/promise.js:693:18

  - promise.js:638 Promise._fulfill
    [global]/[bluebird]/js/release/promise.js:638:18

  - promise_array.js:126 PromiseArray._resolve
    [global]/[bluebird]/js/release/promise_array.js:126:19

  - promise_array.js:144 PromiseArray._promiseFulfilled
    [global]/[bluebird]/js/release/promise_array.js:144:14

  - promise.js:574 Promise._settlePromise
    [global]/[bluebird]/js/release/promise.js:574:26

  - promise.js:614 Promise._settlePromise0
    [global]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [global]/[bluebird]/js/release/promise.js:693:18

  - async.js:133 Async._drainQueue
    [global]/[bluebird]/js/release/async.js:133:16

  - async.js:143 Async._drainQueues
    [global]/[bluebird]/js/release/async.js:143:10

  - async.js:17 Immediate.Async.drainQueues
    [global]/[bluebird]/js/release/async.js:17:14




The error message is correct, there is no access to github directly as all traffic goes through an http proxy.

Expected behavior

https should be used to clone the starter as it works everywhere instead of git.

Steps to reproduce

1. Set up an environment where you cannot access to github.com with ssh/git

2. Run gatsby new gatsby-site

Suggested change

Replace hostInfo.git() by hostinfo.https() in https://github.com/gatsbyjs/gatsby/blob/af5c9c86a604d2f6d441a793d1df3cd7b2cba793/packages/gatsby-cli/src/init-starter.js#L69

Most helpful comment

For me the above command didnt work, but the below command did the trick,

git config --global url."https://github.com/".insteadOf "[email protected]:"

All 5 comments

should a fairly harmless change I think? Care to send a PR? :)

yes PR is on the way :)

Actually, I don't think we need to change anything in gatsby

Git already provides a way to rewrite urls :

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

(The trick was found on https://stackoverflow.com/questions/21260689/force-bundle-install-to-use-https-instead-of-git-for-github-based-gems )

Let's just close this issue :)

For me the above command didnt work, but the below command did the trick,

git config --global url."https://github.com/".insteadOf "[email protected]:"

All this can be solved........... By two simple steps actually three:
1.) Open GIT BASH
2.) Type the command: _gatsby new gatsby-site https://github.com/gatsbyjs/gatsby-starter-hello-world..._
3.) And from your TERMINAL type _gatsby develop_

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andykais picture andykais  Â·  3Comments

jimfilippou picture jimfilippou  Â·  3Comments

rossPatton picture rossPatton  Â·  3Comments

dustinhorton picture dustinhorton  Â·  3Comments

3CordGuy picture 3CordGuy  Â·  3Comments