gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.31k forks source link

Make gatsby new clone using https instead of ssh #3399

Closed flegall closed 6 years ago

flegall commented 6 years ago

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

jquense commented 6 years ago

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

flegall commented 6 years ago

yes PR is on the way :)

flegall commented 6 years ago

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 :)

vickylance commented 6 years ago

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

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

abhinavjonnada82 commented 6 years ago

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