How to run a ruby script within bundler context?

后端 未结 3 1663
深忆病人
深忆病人 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 12:53

    Pass the script name to the ruby command:

    bundle exec ruby script_name
    

    If you also want the Rails environment:

    bundle exec rails runner script_name
    

提交回复
热议问题