Stream: helpdesk (published)

Topic: Set environment variable before another package is loaded


view this post on Zulip DrChainsaw (Mar 15 2024 at 14:49):

Assume I have a module like this:

module MyModule

import SomePackage

Is there a way to have a piece of code like this

if !haskey(ENV, "SOMEPACKAGE_CONFIG")
  ENV["SOMEPACKAGE_CONFIG"] = "BLAH"
end

So that it always runs before import SomePackage?

If I just put it right before the import it seems to only run when MyModule is precompiled or in some other way is new (updated, changed if deved etc.) while if I put it in __init__() it runs after.


Last updated: Dec 28 2024 at 04:38 UTC