Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Set path for Ruby function library

I have some ruby functions I wrote and put in a file ( NumLib.rb) that I want to call from ruby code in Widget.lym.
Both files are in the 'local' directory. For me it is 'C:\Users\dave\KLayout\macros' .
So Widget.lym looks like:

module Widget

include RBA
require 'NumLib'

end

On my machine (Windows 7) the IDE finds NumLib.rb just fine and runs the functions it contains as called upon.
For a colleague running windows 10, we set it up the same way, but the IDE can't seem to find NumLib.rb.
We fixed it by explicitly writing

require 'c:Users\\KLayout\macros\NumLib'

How do we set the default search path that the IDE uses to find required .rb files?

Thanks,

Dave

Comments

  • Hi Dave,

    the usual way to making Ruby find a file next to another is to use:

    inst_dir = File.dirname(__FILE__)
    $:.member?(file_dir) || $:.push(inst_dir)
    
    require "NumLib.rb"
    

    Matthias

  • And also in ruby files is possible to specify the home directory
    #
    fn =ENV['HOME']+"\\Klayout\\klayout_library.gds"

    And it will work in all computers :)
    I try always to use the home directory as connection for programs and I use symbolic links to not have all the information in the user directory (external disk or other places in the computer)
Sign In or Register to comment.