Stream: helpdesk (published)

Topic: ✔ Start process with unset project


view this post on Zulip Timothy (Mar 08 2023 at 14:38):

I'm trying to create Julia processes that aren't initially bound to a project, and then bind themselves to a project on demand. I'm wondering if I can create a result similar to julia --project=X if a Julia process is created with an "unset project" (or similar) such that a Pkg.activate(X) (or similar) yeilds a result indistinguishable from julia --project=X.

view this post on Zulip Fredrik Ekre (Mar 09 2023 at 07:23):

If you haven't set JULIA_LOAD_PATH then those area already equivalent.

view this post on Zulip Timothy (Mar 09 2023 at 08:34):

I'm thinking of setting JULIA_LOAD_PATH to @v#.#:@stdlib then running push!(LOAD_PATH, "@") and set_active_project(<project>) might work.

view this post on Zulip Fredrik Ekre (Mar 09 2023 at 08:37):

What are you trying to achieve? If you can manipulate the environment variable I would do only that and nothing from Julia.

view this post on Zulip Timothy (Mar 09 2023 at 08:54):

I'm trying to create Julia processes that aren't initially bound to a project, and then bind themselves to a project on demand.

I have a way of creating Julia daemon processes for a particular project, but when they start up they take ~2s to do the setup and compiling. So, I'm thinking I could perhaps create an "unbound" daemon process in reserve, and then when requested simply set its project and hand it over, instead of going through the whole initialisation process at that point.

view this post on Zulip Fredrik Ekre (Mar 09 2023 at 08:59):

Okay, the I would just do push!(empty!(LOAD_PATH), "new/project") or something like that

view this post on Zulip Timothy (Mar 09 2023 at 12:01):

Timothy said:

I'm thinking of setting JULIA_LOAD_PATH to @v#.#:@stdlib then running push!(LOAD_PATH, "@") and set_active_project(<project>) might work.

This seems to work

view this post on Zulip Notification Bot (Mar 09 2023 at 12:01):

Timothy has marked this topic as resolved.

view this post on Zulip Fredrik Ekre (Mar 09 2023 at 12:07):

You might as well put the @ in the environment variable too then.

view this post on Zulip Timothy (Mar 09 2023 at 13:08):

It doesn't matter what the project/load-path is during julia startup?

view this post on Zulip Fredrik Ekre (Mar 09 2023 at 13:09):

No

view this post on Zulip Timothy (Mar 10 2023 at 03:37):

Oh good, that resolves some of my worries. I took note of this line in the environment variables docs:

JULIA_PROJECT must be defined before starting julia; defining it in startup.jl is too late in the startup process.

view this post on Zulip Fredrik Ekre (Mar 10 2023 at 08:37):

You are not using JULIA_PROJECT though.

view this post on Zulip Timothy (Mar 10 2023 at 12:40):

Mmm, I just took this to say the full effect of setting JULIA_PROJECT could not be simulated/applied after launching julia


Last updated: Dec 28 2024 at 04:38 UTC