Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git clone results in "fatal: Unable to find remote helper for 'https'" when using a local git executable #113

Closed
kittaakos opened this issue Aug 25, 2017 · 6 comments

Comments

@kittaakos
Copy link
Contributor

... and it works as expected both when I use the executable with dugite and when I use child_process. Maybe it is not the appropriate channel to ask for help, but I was unable to clone any public repositories (without required authentication) when I set the LOCAL_GIT_DIRECTORY environment variable. Does anyone have a pointer what am I doing wrong? Any help would be greatly appreciated.

Here a very stupid simple module that does the cloning with both dugite and with the child_process.

index.js

const fs = require('fs');
const path = require('path');
const gp = require('dugite').GitProcess;
const cp = require('child_process');


getVersionWithDugite();
cloneWithDugite('https://github.com/desktop/dugite.git');

process.env.LOCAL_GIT_DIRECTORY = '/usr/local/';

getVersionWithDugite();
cloneWithDugite('https://github.com/desktop/what-the-changelog.git');

getVersionWithChildProcess();
cloneWithChildProcess('https://github.com/desktop/dugite-native.git');


function getVersionWithDugite() {
    gp.exec(['--version']).then(result => {
        console.log("_____________________");
        console.log("OUT", result.stdout.trim());
        console.log("ERR", result.stderr.trim());
        console.log("_____________________");
    });
}

function cloneWithDugite(url) {
    gp.exec(['clone', url]).then(result => {
        console.log("_____________________");
        console.log("OUT", result.stdout.trim());
        console.log("ERR", result.stderr.trim());
        console.log("_____________________");
    });
}

function getVersionWithChildProcess() {
    cp.execFile('/usr/local/bin/git', ['--version'], (error, stdout, stderr) => {
        console.log('stdout', stdout)
        console.log('stderr', stderr)
    });
}

function cloneWithChildProcess(url) {
    cp.execFile('/usr/local/bin/git', ['clone', url], (error, stdout, stderr) => {
        console.log('stdout', stdout)
        console.log('stderr', stderr)
    });
}

package.json

{
  "name": "dugite-clone",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "kittaakos <kittaakos@gmail.com>",
  "license": "ISC",
  "dependencies": {
    "dugite": "^1.39.0"
  }
}

@shiftkey
Copy link
Member

@kittaakos ah, I think I know this one.

We set GIT_EXEC_PATH to the same known location, and at least on macOS this path may be something different. You can check this by running git --exec-path:

$ git --exec-path
/usr/local/Cellar/git/2.14.1/libexec/git-core

Two potential ways out of this:

  • don't set GIT_EXEC_PATH if you already have LOCAL_GIT_DIRECTORY set, assume the user has configured Git correctly
  • run git --exec-path and set it as an environment variable if you have LOCAL_GIT_DIRECTORY set

@kittaakos
Copy link
Contributor Author

Thank you, @shiftkey! Both approaches work perfectly. I would say; when one sets the GIT_LOCAL_DIRECTORY variable one should be aware of setting the GIT_EXEC_PATH environment variable too.

Unfortunately, even if I set both environment variables, the GIT_EXEC_PATH gets overridden here.

The following would be my expectation about the behavior; when the custom GIT_EXEC_PATH is set, then dugite itself does not try to locate it again, but blindly uses the user specified path, just like with the LOCAL_GIT_DIRECTORY .

Would that change make sense to you? Do you accept contributions? Also, please correct me if I misunderstood something. Thanks in advance!

@shiftkey
Copy link
Member

Would that change make sense to you?

Yes! This makes sense, it was just me not considering the full range of scenarios. And I like respecting the existing environment variable, as it avoids us executing a git --exec-path ourselves.

Do you accept contributions?

I do! Happy to review and work with you on a fix if you're feeling up to it!

@kittaakos
Copy link
Contributor Author

Awesome! I was put on another project, but I do my best to come up with a PR in this week. Bear with me.

kittaakos added a commit to kittaakos/dugite that referenced this issue Aug 28, 2017
And will not be calculated based on the Git directory.

Signed-off-by: Akos Kitta <kittaakos@gmail.com>
kittaakos added a commit to kittaakos/dugite that referenced this issue Aug 28, 2017
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
kittaakos added a commit to kittaakos/dugite that referenced this issue Aug 28, 2017
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
@kittaakos
Copy link
Contributor Author

PR: #114.

kittaakos added a commit to kittaakos/dugite that referenced this issue Aug 29, 2017
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
shiftkey added a commit that referenced this issue Aug 30, 2017
GH-113: Made sure that `GIT_EXEC_PATH` is used as is when configured.
@shiftkey
Copy link
Member

Fixed by #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants