Skip to content

Autorun(-early) doesn't seem to run when lym files are inside a package #21

Closed

Description

@davidnhutch

Something is broken about the macro autorun feature, under certain circumstances, in 0.25

Assumed problem:

It seems the autorun-on-startup feature probably only looks in KLayout/macros folder right now. I think it should also look in KLayout/salt/package-name/macros and KLayout/group-name/package-name/macros. This enables dependencies between packages without needing to "load 'filename.rb'" to manually run one code from the other code.

Steps to reproduce the problem:

  1. Create file1.lym and file2.lym under macros folder (the main macros folder, not inside a package)

file1.lym:

# Choose properties > Run early on startup
module MyModule
  class MyClass
    def MyMethod
      p 'hello world'
    end
  end
end

file2.lym:

include MyModule
MyClass.new.MyMethod
  1. Make file1.lym be auto-run early.
  2. Close then open KL.
  3. Run file2.lym via the Macro Editor. It works! (Nothing is wrong.)
  4. Now, create a package named "mypackage" using Tools > Manage Packages. Use the Ruby template.
  5. Move file1.lym and file2.lym to salt/mypackage/macros using the OS filesystem. (Or create them anew there and delete the old ones.)
  6. Close then open KL.
  7. Try to run file2.lym via the Macro Editor. It doesn't work. (Apparently file1.lym has not run, so it doesn't recognize MyModule.)
  8. Now, if you manually run file1.lym in the Macro Editor, then run file2.lym, it works. This indicates that there is nothing broken about the code. It is just that file1.lym is not autorunning on startup.

Activity

  1. klayoutmatthias commented on Nov 22, 2017

    @klayoutmatthias
    Collaborator

    A model ticket! Thanks a lot.

    I see the issue. You're are probably referring to our discussion in the forum :-)

    My suggestion would be to use plain ruby libraries in the "ruby" subfolder. They can be included through the standard "require".

    But I'll take a look at the issue. I don't see the reason quickly so I have to investigate the issue. Thanks for reporting the problem.

  2. klayoutmatthias commented on Dec 2, 2017

    @klayoutmatthias
    Collaborator

    I have tried to provide a fix on the master branch. The fix goes a bit deeper than I was expecting. Maybe you have a chance to test it and give feedback.

    Thanks,

    Matthias

  3. added a commit that references this issue on Jan 8, 2018
  4. added a commit that references this issue on Jul 24, 2018
  5. added a commit that references this issue on May 11, 2026
  6. added a commit that references this issue on May 14, 2026
  7. added a commit that references this issue on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions