* * *

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

vfclists

  • Hero Member
  • *****
  • Posts: 823
    • 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.
Windows - Lazarus 1.0.8/FPC 2.6.0
Linux - Lazarus 1.4.4 /FPC 2.6.4

lainz

  • Hero Member
  • *****
  • Posts: 2087
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: 823
    • 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?
Windows - Lazarus 1.0.8/FPC 2.6.0
Linux - Lazarus 1.4.4 /FPC 2.6.4

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
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

  • Full Member
  • ***
  • Posts: 242
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
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

  • Full Member
  • ***
  • Posts: 234
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
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

  • Full Member
  • ***
  • Posts: 242
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!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus