-
Notifications
You must be signed in to change notification settings - Fork 104
feat: persist JULIA_* ENV variables used as user settings
#1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
JULIA_ ENV variables used as user settingsJULIA_* ENV variables used as user settings
|
Hm, ok, this is interesting, but I also think this is too magical and probably out of scope for Juliaup... I think at the end of the day what this amounts to is a desire to have an option to configure the things that are currently configured via env variables via a global config file. To me that kind of makes sense. But I think really this should be done at the Julia level, i.e. if we want a global config file for these things, then Julia should add support for that. I could see Juliaup playing in a role in such a setup, for example it could provide command line options to modify these global configuration options. |
Maybe I missed something but just reading this in isolation it would be very surprising behavior to me. It seems like this is a job for https://direnv.net/ maybe? |
I'm happy to discuss. I would personally prefer
Yea, Converting to draft for now, I'm open to ideas! |
|
So you want a way to persist these type of settings in some other way than using the environment? Having such an option is ok on its own, it is the automatic persistence of these by just setting options and launching julia that didn't really sit so well with me. Having |
Yes, like |
|
Yeah, I could definitely imagine a world where there are lots of other things to configure with But also wondering whether |
Add Persistence for Julia Environment Variables
One of my biggest inconveniences with Julia is that you need to set the knobs very often in many places (
startup.jletc)This PR adds automatic persistence of all the Julia environment variables except the
JULIA_PROJECTone. When Julia is launched with environment variables set (e.g.,JULIA_NUM_THREADS=8), they are automatically saved to~/.julia/juliaup/juliaup.jsonand reused in future launches, eliminating the need to set them every time.This is particularly important for me because I always want some knobs to be set; specifically:
JULIA_PKG_SERVER=juliahub.comJULIA_PKG_USE_CLI_GIT=trueJULIA_NUM_THREADS=8JULIA_CPU_TARGET=generic(yes, generic :) )and so on
Why not
.bashrc?Well,
.bashrcis not cross platform and not standard. It's also significantly harder to edit.bashrcthan running a julia command once to set the defaults, especially if you're trying to explain this to a new julia user.Why not
startup.jl?Some julia environment variables must be set before runtime (startup.jl is too late). This feature allows users to configure their Julia environment once without needing shell scripts or manual environment variable management.
Example Usage
Implementation
Changes
src/config_file.rsjulia_env_variables: HashMap<String, String>toJuliaupConfigSettingsSettings.JuliaEnvironmentVariablessrc/utils.rsget_julia_environment_variables()listing 58 supported variablesJULIA_PROJECTper Julia documentationsrc/bin/julialauncher.rsprocess_julia_environment_variables()to handle persistence.envs()Behavior
Config File Format
Variables appear in the Settings section:
{ "Settings": { "VersionsDbUpdateInterval": 1440, "JuliaEnvironmentVariables": { "JULIA_NUM_THREADS": "8", "JULIA_EDITOR": "vim", "JULIA_PKG_SERVER": "https://pkg.julialang.org" } } }Testing
Added comprehensive test suite:
Unit Tests (in
src/utils.rs):JULIA_PROJECTexclusionIntegration Tests (new file
tests/env_var_persistence.rs):