Using ruby 1.9.3 on Ubuntu 14.04, I can upload files from the current directory to irb using the following command line:
irb -I . -r foo.rb
where foo.rb is the file that I want to download from the current directory. The -I option is needed to add the current directory ( . ) To the ruby boot path, as described on the ruby man page. This allows require files from the current directory, which is what the -r option to irb .
The key thing that was not obvious to me when I had this problem was the -I option. After that, you can call require 'foo.rb' from irb for any files in the current directory. And, of course, you can specify any directory that you want, and not just . with the option -I . To include multiple directories in the download path, separate them with a colon (:), for example:
irb -I foo/:bar/:baz/
This command will add the foo , bar and baz directories to the ruby boot path.
The ultimate alternative is to use a relative or absolute path to the file when using require or -r to load the file:
irb -r ./foo.rb
or from irb :
> require './foo.rb'
wachr Jan 09 '15 at 22:46 2015-01-09 22:46
source share