How do I specify local .gem files in my Gemfile?

前端 未结 7 1038
野的像风
野的像风 2020-12-22 18:16

I have a couple of gem files which I install via gem install xx.gem. Can I tell Bundler to use them? Or do I have to specify the source path?

7条回答
  •  轮回少年
    2020-12-22 18:53

    Seems bundler can't use .gem files out of the box. Pointing the :path to a directory containing .gem files doesn't work. Some people suggested to setup a local gem server (geminabox, stickler) for that purpose.

    However, what I found to be much simpler is to use a local gem "server" from file system: Just put your .gem files in a local directory, then use "gem generate_index" to make it a Gem repository

    mkdir repo
    mkdir repo/gems
    cp *.gem repo/gems
    cd repo
    gem generate_index
    

    Finally point bundler to this location by adding the following line to your Gemfile

    source "file://path/to/repo"
    

    If you update the gems in the repository, make sure to regenerate the index.

提交回复
热议问题