When I set the load path on command line using -I, is it ALWAYS the case that this path is the first item in the $: array?
Is it ever possible that this path is NOT the first item in the $: array?
When I set the load path on command line using -I, is it ALWAYS the case that this path is the first item in the $: array?
Is it ever possible that this path is NOT the first item in the $: array?
That mostly depends on version of Ruby interpreter/virtual machine you're using, but, generally, that's the purpose of -I option: you should be able to override default $LOAD_PATH with it.
If you want to supply $LOAD_PATH components using command-line that would be applied in other position, you're free to implement your own command-line options, such as
require 'getoptlong' opts = GetoptLong.new(['--include', '-I', GetoptLong::REQUIRED_ARGUMENT ]) opts.each { |opt, arg| $LOAD_PATH << arg if opt == '--include' } -I in command line of Ruby interpreter/virtual machine and using some other command-line option from application itself (as done in this example) is portable across operating systems and various Ruby versions. The behavior of $LOAD_PATH is well-defined. However I suspect that some versions (or platforms) might lack command-line (for example, I'm not sure that you can start a program with command-line arguments on Android platform or in S60 port).