How to run a ruby script within bundler context?

后端 未结 3 1669
深忆病人
深忆病人 2021-02-01 12:04

I have a Ruby script called foo.rb, and I want to run it within the context of the bundler environment. How?

bundle exec foo.rb doesn\'t work, because exec

3条回答
  •  故里飘歌
    2021-02-01 13:00

    For instance, I wanted to use the same version of Rubocop as my Rails app and not the latest system one, so doing this in a script:

    require 'bundler'
    Bundler.require
    
    # ...
    

    Allowed me to use my app's version of rubocop.

提交回复
热议问题