Find out which gems require native c extensions from a Gemfile?

无人久伴 提交于 2019-12-21 01:48:12

问题


I just recently started shifting attention towards deploying Ruby apps atop TorqueBox which of course is built atop Jruby. Hitherto I have been basically performing a bundle install and then tackling each gem along the way to jrubydom, but I've hit a couple gems that have taken me some considerable time to resolve due to needing to reimplement large portions of them.

Is there a way to invoke bundler or rubygems to run through all gems and their deps to test if they require native c extensions and then return such a list? It sure would be nice to tackle some of the more minor items or even to know if it is worthwhile to tackle a project in terms of moving it to jruby.


回答1:


You can use JRuby Lint for that. It will will check for some gems requiring C extension and even list alternative (based on this list).




回答2:


Based on the fact that gems with native extensions usually have an /ext directory, I made a simple oneliner that finds these gems:

puts `bundle show --paths`.split("\n").select{|dep| File.directory?("#{dep}/ext") }.map{|dep| dep.split('/').last }.join(', ')

You can do this on the command line with this command:

$ bundle show --paths | ruby -e "STDIN.each_line {|dep| puts dep.split('/').last if File.directory?(File.join(dep.chomp, 'ext')) }"


来源:https://stackoverflow.com/questions/24312872/find-out-which-gems-require-native-c-extensions-from-a-gemfile

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