atoms-to-github插件已停止维护且无法在atom 1.60+中运行,因依赖的api被移除、结构变更及electron上下文隔离限制;推荐改用atom内置github包配合gh cli实现可靠自动化。

Atoms-To-Github 插件已停止维护,且无法在 Atom 1.60+ 版本中正常工作 —— 它依赖的 atom.project.getPaths API 在 v1.60 被移除,启动即报 TypeError: atom.project.getPaths is not a function。
为什么 atoms-to-github 现在根本装不上
该插件最后一次更新是 2018 年,作者已归档仓库(atoms-to-github GitHub repo marked as archived)。它调用的底层 Atom API 已被彻底废弃:
-
atom.project.getPaths()→ 替换为atom.project.getPathsAsync()(返回 Promise) -
atom.workspace.getActivePaneItem()返回值结构变更,旧代码直接取.getPath()会炸 - 未适配 Electron 13+ 的上下文隔离(Context Isolation)限制,
require('child_process')调用被拦截
即使你用 apm install atoms-to-github 强行安装,激活时控制台必出红字,插件菜单项不显示。
替代方案:用 github 官方包 + 手动 push
Atom 自带的 github 包(默认启用)已覆盖其核心诉求 —— 把当前文件/项目推到 GitHub。关键差异在于:它不自动创建仓库,但更可靠、持续更新:
- 确保项目已初始化 Git:
git init && git add . && git commit -m "init" - 在 GitHub 新建空仓库,复制 HTTPS 地址(如
https://github.com/username/repo.git) - 终端执行:
git remote add origin https://github.com/username/repo.git && git push -u origin main - 之后右键文件 →
Github: Open on GitHub或Github: Copy URL to Clipboard即可跳转
注意:github 包不支持“一键创建远程库并推送”,这步必须手动完成 —— 这反而是更可控的做法。
如果坚持要自动化创建远程库,只能用外部 CLI
Atom 本身不再允许插件直接调用 GitHub API 创建仓库(涉及 token 权限和 CORS),但你可以借助命令行工具链补位:
- 安装
ghCLI:brew install gh(macOS)或sudo apt install gh(Ubuntu) - 登录:
gh auth login(选 GitHub.com + HTTPS + Login with a web browser) - 在项目根目录运行:
gh repo create --public --push(自动创建、关联、推送) - 把这条命令绑定为 Atom 的自定义 keymap(
keymap.cson)或 script 插件快捷键
这是目前唯一能复现 atoms-to-github “创建+推送”流程的方式,且比原插件更安全(token 由 gh 管理,不硬编码进 Atom 配置)。
真正容易被忽略的是:很多用户试图在离线环境或企业内网部署 atoms-to-github,却没意识到它连基础的 GitHub API 调用都走不通 —— 不是网络问题,是代码层面已失效。别浪费时间 patch,直接切到 gh + github 包组合。











