简体   繁体   中英

How do I pass ruby arguments to pry-rescue?

I have a Ruby script that I run like this:

$ ruby -I my_libs my_script.rb

I want to run it with pry-rescue but I can't figure how to pass arguments to Ruby (the interpreter, not the script). The pry-rescue documentation implies that you just replace ruby with rescue to use it, so I thought this would work:

$ rescue -I my_libs my_script.rb

but it doesn't.

Is there a way to pass command-line arguments to ruby via rescue ?

As a work-around, you can pass arguments via the RUBYOPT environment variable. So here is one way to pass ruby arguments via rescue :

$ RUBYOPT='-I my_libs' rescue my_script.rb

Note however, as per man ruby , that RUBYOPT can contain only a subset of the available ruby options, so this is not a complete solution to the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM