Improve git cloning plugins via clash proxy

While cloning is supported in the terminal and can be successfully configured in the macro panel, it is completely impossible to configure the plugin management panel, and I cannot even test it.

According to Alternate plugin repositories broken? - #7 by FlorianPircher ,
Glyphs is using libgit2 for its Git-handling, including cloning.
macOS doesn’t allow any connections over http (no s) any more.

Solutions I thought of:

Make user able to manually switch the Git (to system Git) used by the plugin management panel,
or able to configure libgit2 thus to use a proxy;
or at least allow the plugin management panel to recognize plugins that user manually clone and install to ‘~/Library/Application Support/Glyphs 3/Repositories/PluginName’, I can even accept displaying “This was manually installed by the user” to differentiate them;
or provide a manual installation script which uses the system Git to ensure that the cloned data has not been tampered with, but the script might be incompatible with local plugins.plist.

I don’t suggest using git in macro panel.

What I tried:

Needless to say attempts in the terminal, I later learned that the Git configurations for the three environments are not shared. Just skip to the configuration process in the macro panel: all commands were generated by deepseek:
Incidentally, Python also failed to install in the plugin management panel, so I manually downloaded and installed it later(I might provide a script to automate this later; I saw others on the forum have encountered this problem).
The working directory in the macro panel is /, and this script will show the files contained within it: home usr bin sbin etc var:

import os
print("CurrentWorkingDirectory:", os.getcwd())
print("\nContentList:")
for item in os.listdir('.'):
    print(item)

I won’t go into the details, the result is simple:
Add proxy settings to the global Git configuration; the command in the macro panel is:

import subprocess

subprocess.run(['git', 'config', '--global', 'http.proxy', 'http://127.0.0.1:7890'])
subprocess.run(['git', 'config', '--global', 'https.proxy', 'http://127.0.0.1:7890'])

Then the clone test will succeed:

import subprocess
import tempfile

# Use a temporary directory (which is usually writable).
temp_dir = tempfile.mkdtemp()
result = subprocess.run(
    ['git', 'clone', '--depth', '1', 'https://github.com/octocat/Hello-World.git', f'{temp_dir}/test_repo'],
    capture_output=True,
    text=True
)

if result.returncode != 0:
    print("Cloning failed:", result.stderr)
else:
    print("Cloning successful! Path:", temp_dir)

It succeeded in the macro panel, but it still failed in the plugin management panel, still showing the error: Failed to clone repository from [repo URL] to [local path].

No one else needs to repeat these tests:

Try1

Set proxy environment variables:

import os

# 设置代理环境变量Set proxy environment variables
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'
os.environ['GIT_SSL_NO_VERIFY'] = '1'

# Verify
print(os.environ.get('HTTP_PROXY'))

outputs:http://127.0.0.1:7890
Reboot Glyphs.app, do verification only:

import os

# Verify
print(os.environ.get('HTTP_PROXY'))

outputs:none. Try1 failed.

Try2

Modify the launchd environment variable (Mac system level)
(Mac system level)

bash

#为 GUI 应用设置代理Set up a proxy for a GUI application

sudo launchctl setenv HTTP_PROXY http://127.0.0.1:7890
sudo launchctl setenv HTTPS_PROXY http://127.0.0.1:7890

Reboot Glyphs.app, do verification only, outputs:none.Try2 failed.

Try3

创建 Git 别名脚本Create a Git alias script:

import subprocess
import os

# 创建代理包装脚本Create proxy wrapper script
wrapper_script = '''#!/bin/bash
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export GIT_SSL_NO_VERIFY=1
/usr/bin/git "$@"
'''

script_path = os.path.expanduser('~/git-proxy-wrapper.sh')
with open(script_path, 'w') as f:
    f.write(wrapper_script)

# 添加执行权限Add execute permission
os.chmod(script_path, 0o755)

# 让 Glyphs 使用这个包装脚本Let Glyphs use this wrapper script
subprocess.run(['git', 'config', '--global', 'core.gitProxy', script_path])

print(f"✅ 代理包装脚本已创建Proxy packaging script has been created: {script_path}")

The plugin management panel and plugin list are no longer accessible.After restoring the configuration(see script below), the plugin list was retrieved normally.

import subprocess

# 1. 移除刚才设置的包装脚本Remove the wrapper script just set
subprocess.run(['git', 'config', '--global', '--unset', 'core.gitProxy'])

# 2. 恢复正常 Git 配置Restore normal Git configuration
subprocess.run(['git', 'config', '--global', 'http.proxy', 'http://127.0.0.1:7890'])
subprocess.run(['git', 'config', '--global', 'https.proxy', 'http://127.0.0.1:7890'])
subprocess.run(['git', 'config', '--global', 'http.sslVerify', 'false'])

# 3. 删除包装脚本Delete the wrapper script
import os
script_path = os.path.expanduser('~/git-proxy-wrapper.sh')
if os.path.exists(script_path):
    os.remove(script_path)

print("✅ 已恢复配置Configuration restored")

Try4

Setting clash to global mode (instead of the previous rule mode) still results in “Failed to clone repository from [repo URL] to [local path]”.

I’ll have a look at your complete report later, but for a start, when you manually clone a repository, double-click the plug-in file (.glyphsPlugin/.glyphsReporter/…) and it will be copied to

~/Library/Application Support/Glyphs 3/Plugins/PluginName.glyphsPlugin

The Repositories folder is where Glyphs stores the repositories it is cloning, but Glyphs always adds a symlink in the Plugins folder pointing to the .glyphsPlugin/.glyphsReporter/… file.

1 Like

Thank you!! I know this and have been using manually-installed plugins for a while.