How to require file via absolute and relative paths in Crystal?

There’s a file, just a single file, there’s no shards or anything else.


I want to require it in another file in another folder


This won’t work

require "/alex/projects/inspector/inspector"
require "/alex/projects/inspector/"

This also not working


require "inspector"
require ""
require "./inspector"
require "./"


I would like to avoid using shards etc. as I have no plans to share that file or publish it. It’s just a file that used by couple of other files in different locations.

I solved it by creating symlink

ln -s /alex/projects/inspector/ /alex/projects/my-project/

require "./inspector"

You can use relative paths, see documentation about requiring files: require "../inspector/inspector" should work.