I have this macro :
That should cd into a project I have that is already versioned under git and then git add all the files and commit them and then push them.
Running these same commands from my shell works.
However from KM, nothing seems to happen. Nothing gets pushed and I am not quite sure why nor how I can debug this.
Thank you for any help.
My guess is that KM does not know of Git command.
How then can I achieve what I want to do?
It is probably a shell path issue. the KM shell script does NOT use your normal path you see via Terminal. Seems like we talked about this before. Look in the KM Wiki under Execute Shell Script.
The path is correct though.
For example this works :
And creates a file in the correct place.
It's the git commands that don't work.
It doesn't know the path to your git command files. That dir is what needs to be in the path.
Thank you @JMichaelTX
I forgot about providing the full paths to external commands. My bad.
Now it actually commits and adds them but can’t push.
I get an error :
git credential-osxkeychain is not a git command
I googled everything and I can’t find a solution to this. The thing is that I sign my commits with GPG and since KM can’t read my configs, I guess I get these errors.
I tried setting my PATH variable to what I have in my shell too but still get the same error.
Also strangely I don’t have
credential-oxskeychain command in my shell and yet git commit and git push all work.
But on KM, I can’t git push.
It seems that KM cannot read this
credential-osxkeychain command whilst my zsh shell can.
Or perhaps KM does not have access to Keychain whilst my shell does. So it can’t authenticate properly.
Would really appreciate any help on this. Automating Git like that would be a dream come true for me.
You are probably running two different git commands.
In the Terminal, when git works, run the command:
and it will tell you which git command you are running.
Make sure you are running that command in your shell script in Keyboard Maestro.
An alternative is that there are other environment variables in the Terminal that are not set in Keyboard Maestro. See the wiki: Path in Shell Scripts and it applies to the PATH as well as any other environment variables that the git command might be using.
I use the correct path for Git. I checked.
Trying to understand what variables I am missing. It’s quite hard so far.
I have a very long PATH in my shell, would it be okay to transfer it to KM in hopes that it would fix this? Here is my PATH :
Ok wow. This worked :
I have no idea how my PATH got to this point.
I am kind of afraid of putting it as a global ENV_PATH variable in preferences but perhaps I shouldn't be.
In any way, thank you @peternlewis and @JMichaelTX
Your PATH scares the daylights out of me.
My guess is that git credential-oxskeychain is calling some sort of sub-command, which it is finding in that path somewhere, and without those path entries, it’s not finding the command, and therefore failing.
I’d be tempted to set the PATH explicitly within the Execute Shell Script. I’d also be tempted to understand all the entries in the PATH and why they are there.
I think you can just add:
to the start of your shell script.
@nikivi, I totally agree with Peter.
It reminds me of Windows Registry, where every app install put a ton of junk in the Registry.
IMO, you need to find someone (a shell/bash expert) to look at your system and help you clean up your path. A path of that length and complexity can't help but slow things down, and maybe even cause confusion by the command line tools that use the path.
But before you start this, be sure to save the existing path.
And please post here if you find out what's going on. I don't know much about this stuff... but this is interesting!