How to avoid the source being overwritten when compiling a Gem?

扶醉桌前 提交于 2019-12-12 04:58:23

问题


I am trying to install eventmachine Gem, however a line needs to be commented out in the source for this to work on Ruby 2.0 on Windows x64.

I have tried modifying the Gem source in the Ruby build folder but each time I run gem install eventmachine it overwrites my changes. From the command line help there does not appear to be a way to rebuild the gem without unpacking fresh source, however there may be a workaround.

Is there a way to build my slightly tweaked source for this Gem?


回答1:


Don't install the gem like that. Instead, build your own version and install that instead by specifying the path to the .gem file that is produced as part of the build process.

I've found the easiest way to get this right is to create a fork, set the fork's git path in your Gemfile, and bundle install which will take care of compiling things and installing them correctly.




回答2:


Ok figured it out thanks to help from @tadman.

Ended up just installing locally from source rather than tweaking the official source downloaded by gem and preventing it from being overwritten. These are the exact steps ...

  • Clone locally from Github (or wherever)
  • Make your changes to the source
  • If there is a .gemspec file in the root directory
    • Open terminal in the directory and enter gem build GEMNAME.gemspec
    • Finally enter gem install GEMNAME-VERSION.gem
  • If there is not .gemspec but there is a file called "gem" or "build" or something similar , then you may have to build using rake according to this reply


来源:https://stackoverflow.com/questions/16310793/how-to-avoid-the-source-being-overwritten-when-compiling-a-gem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!