Recent

Author Topic: Why can TProcess run 'git status' but not 'git remote show origin'?  (Read 4977 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
I am using TProcess to run git commands by passing the directory to execute the command in as well as the command itself.

When the command is a local command like 'git status' or 'git branch' the output is okay. 'git remote show origin' results in an error.

Is the problem likely to be with the nature of the 'git remote show origin' itself or is it something within TProcess? 'git remote show origin'  requires a remote connection via ssh but they key has been added to the ssh-agent so it should work fine.

'git remote show origin' executes an ssh command but as I have added the key via keychain it doesn't require a password.
Lazarus 3.0/FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #1 on: February 23, 2017, 01:55:43 pm »
you can show us the code?

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #2 on: February 23, 2017, 02:13:09 pm »
After further tests it seems that the environment created by TProcess does not inherit the ssh-agent key settings. After adding a uploading the remote with a password less authorization key the commands work.

Is there a way to get TProcess to inherit the settings that a 'bash' or a 'screen'  session would automatically acquire?
Lazarus 3.0/FPC 3.2.2

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #3 on: February 23, 2017, 02:45:26 pm »
Copy the relevant keys from environment into .environment ?

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #4 on: October 18, 2017, 04:29:24 am »
I know this is an old post, but I'm having almost the exact same issue (git pull).

Marcov, what do you mean copy the keys from environment to .environment?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #5 on: October 18, 2017, 11:48:00 am »
You can set the environment of TProcess by modifying its environment property.

I interpreted vfclists' " not inherit ssh-agent key settings"  as something not propagating in the environment variables.

mse

  • Sr. Member
  • ****
  • Posts: 286
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #6 on: October 18, 2017, 01:44:42 pm »
IIRC it also could be an issue with ssh and pseudo terminal echo settings. In MSEgit the git commands are executed by the MSEgui TProcess derivate. The code is here:
https://gitlab.com/mseide-msegui/mseuniverse/tree/master/tools/msegit
Binaries:
https://sourceforge.net/projects/mseuniverse/


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #7 on: October 18, 2017, 02:06:55 pm »
Seems that ssh agent forwarding uses the SSH_AUTH_SOCK environment variable.

So
 aprocess.environment.add('SSH_AUTH_SOCK='+getenvironmentvariable('SSH_AUTH_SOCK'));

might help.

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: Why can TProcess run 'git status' but not 'git remote show origin'?
« Reply #8 on: October 18, 2017, 03:06:01 pm »
It turns out I was having a different issue, solved now, but this is very good info regardless, bookmarking.

Thanks guys!

 

TinyPortal © 2005-2018