After installing a gem within a script, how do I load the gem?

后端 未结 4 431
再見小時候
再見小時候 2021-02-04 07:36

I have a small Ruby script that I\'m writing to automate the preparation of a development environment on local machines. Because I can\'t be certain that the rubyzip2

4条回答
  •  渐次进展
    2021-02-04 08:23

    With bundler version higher than 1.10 (to update just run gem install bundler) you can use its new 'inline' feature as described here.

    require 'bundler/inline'
    
    gemfile(true) do
      source 'https://rubygems.org'
      gem 'catpix'
    end
    
    puts Catpix::VERSION
    

    First parameter of gemfile method is whether gems that aren't already installed on the user's system should be installed.

提交回复
热议问题