In Ruby on Rails, is copying vendor/gems/somegem from one project to another project the same as freezing the gem?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 04:18:45

问题


I was told that copying from

vendor/gems/somegem

from proj1 to proj2's folder will essentially freeze the gem into the project. The gem somegem is an internal gem, so there is no repository to install it from. But I wonder how will it work with Rails 3, since we need to use

gem 'somegem'

in the Gemfile, and supposedly when we do a gem list, the name of the gem should show up. What is a good / proper way to do this? thanks.


回答1:


I believe the Gemfile.lock file stores the versions of the gems in use, along with any and all dependencies, so you can essentially copy over your Gemfile and Gemfile.lock and run bundle install




回答2:


In your Gemfile you can tell bundler to get the gem from a local path:

gem 'somegem', :path => "some_path/to/somegem"

If your 'gem' is in fact a plugin then just copy the files to vendor/plugins.

If install.rb in the plugin directory does anything special you may want to run this manually.



来源:https://stackoverflow.com/questions/5380685/in-ruby-on-rails-is-copying-vendor-gems-somegem-from-one-project-to-another-pro

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