__FILE__ path when "--static" build

Hello.

Is __FILE__ and __DIR__ a compile-time path for a --static build?
Is there a way to get the runtime path from __DIR__ with the --static flag?

Thanks.

Hi!

What do you want to do?

--static or not is irrelevant.

  • __FILE__ is the path to the current source code file.
  • __DIR__ is the path to the directory containing the current source code file.
  • PROGRAM_NAME is what a lot of other environments expose as $0 or the first argv element.
  • Process.executable_path is the path to the invoked binary.
3 Likes

Thanks for the answers, both of you!
I’m building a CLI tool and wanted to know the path of the binary currently running, regardless of the current directory.
So what I needed was a “Process.executable_path”. Thank you, that was very helpful.