简体   繁体   English

如何在 Windows 上修改已安装的 gem?

[英]How to modify an installed gem on Windows?

So I've installed svn2git using Ruby on Windows.所以我在 Windows 上使用 Ruby 安装了 svn2git。 Unfortunately, since git has made the change of Master branch to Main, this has broken the script.不幸的是,由于 git 已将 Master 分支更改为 Main,这破坏了脚本。 I've found the script in我在里面找到了脚本

C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems\svn2git-2.4.0

and made the required modifications.并进行了必要的修改。 How do I recompile / remake this so that when I run svn2git on the command line it uses my modified script?我如何重新编译/重新制作它,以便当我在命令行上运行svn2git时它使用我修改过的脚本?

since git has made the change of Master branch to Main, this has broken the script由于 git 已将 Master 分支更改为 Main,这破坏了脚本

I'm not sure what you mean by "broken";我不确定你所说的“破碎”是什么意思; perhaps you needed to rename master --> main here ?也许您需要在这里重命名master --> main (Or even better, you could make it somehow configurable , not hardcoded?) (或者甚至更好,你可以让它以某种方式可配置,而不是硬编码?)

How do I recompile / remake我如何重新编译/重新制作

This is ruby.这是红宝石。 It's an interpreted language;它是一种解释型语言; you don't need to compile anything.你不需要编译任何东西。

It would be "bad practice" to edit the gem directly on your machine, but this should still work .直接在您的机器上编辑 gem 将是“不好的做法”,但这应该仍然有效 If you run svn2git on the command line right now, then - assuming that's the correct installation (eg you don't also have a ruby 2.6 version installed that's getting picked up?!), it should run your modified code instead.如果您现在在命令行上运行svn2git ,那么 - 假设这是正确的安装(例如,您还没有安装正在使用的 ruby​​ 2.6 版本?!),它应该运行您修改后的代码。


But for a "better" long-term solution, it would be advisable to fork the project , make your change, and install your own version of the project.但是对于“更好”的长期解决方案,建议fork 项目,进行更改并安装您自己的项目版本。

You could also open a pull request with your change, in case the original author is still active and willing to release an update.您还可以打开一个包含更改的拉取请求,以防原作者仍然活跃并愿意发布更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM