-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Set temporary env whenever Julia is started with --project=@temp
#51149
Conversation
Similar to #49061 (@KristofferC), and discussion there of whether we should spell this |
This could breaks existing scripts, though. How about using |
#50864 uses |
35e7ff1
to
b9e981e
Compare
--project=temp
--project=--temp
2a981b8
to
b7663be
Compare
You have now changed it to |
The Although |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find that argument compelling. Should this have a NEWS.md entry perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if someone could type a blurb for the NEWS file, this looks good to me
I really appreciate the functionality but sorry must it be spelled I much prefer the original |
It can be a somewhat common pattern in compiler drivers like Julia, gcc, or clang. E.g. |
a420a34
to
576145e
Compare
As conversations, here and in #49061, have gravitated toward
|
reading through both these issue threads, I would not call it "gravitating," more just stalled after that being said, OSS is not a vote, and I am happy to be overruled. just wanted to put my feedback in that I find this syntax quite clunky. @vtjnash that's a good point about the compiler drivers, but I strongly suspect that most users see Julia more like an app than they see it like a compiler |
|
How about an independent command line option? You would invoke this as |
|
in favor of |
Just as an observation for everyone, the pattern to force it to be a directory is to prepend |
Personally, I would prefer if this flag starts with |
Whatever is chosen here, please make it easy and convenient to use. Being able to write (As a side note, on international keyboards |
persistent-ly empty, so it kind of is something is going to have to be special-cased, and I think it's least surprising if that's behind an and I know it has been mentioned a few times so this is a redundant observation, but nonetheless I think it's going unappreciated that |
If we use
I'm learning towards option 1. It would be similar to a deprecation warning. Additionally, we could offer a helpful error message about referring to the shared environment using its absolute path. |
|
5a0f8a4
to
f8e7121
Compare
With the update,
However it does not check for a shared env 👍 I propose that we give Current behavior: (@v1.11) pkg> activate @.
ERROR: not a valid name for a shared environment: .
(@v1.11) pkg> activate @temp
Activating new project at `~/.julia/environments/temp`
(@temp) pkg> activate @stdlib
Activating new project at `~/.julia/environments/stdlib`
(@stdlib) pkg> activate @
Activating new project at `~/.julia/environments`
(@environments) pkg> To new behavior: (@v1.11) pkg> activate @.
# activate the current project
# While `--temp` continues to do what it does,
(@v1.11) pkg> activate @temp
Activating new project at `/tmp/jl_oqUHmk`
(@temp) pkg> activate @stdlib
Activating project at `@stdlib/v1.11`
(@stdlib) pkg> activate @
# activate the active project julia> Pkg.activate("temp"; shared = true) # (edited)
┌ Error: `temp` is an invalid name for a shared environment.
│ To create a temporary environment use `Pkg.activate(; temp = true)`
└ @ Main REPL[10]:2 🚀 If instead Julia should check for a shared-env-temp, I'll modify the alternatefunction load_path_expand(env::AbstractString)::Union{String, Nothing}
# named environment?
if startswith(env, '@')
# `@.` in JULIA_LOAD_PATH is expanded early (at startup time)
# if you put a `@.` in LOAD_PATH manually, it's expanded late
env == "@" && return active_project(false)
env == "@." && return current_project()
env == "@stdlib" && return Sys.STDLIB
if startswith(env, "@scriptdir")
if @isdefined(PROGRAM_FILE)
dir = dirname(PROGRAM_FILE)
else
cmds = unsafe_load_commands(opts.commands)
if any((cmd, arg)->cmd_suppresses_program(cmd), cmds)
# Usage error. The user did not pass a script.
return nothing
end
dir = dirname(ARGS[1])
end
return abspath(replace(env, "@scriptdir" => dir))
end
env = replace(env, '#' => VERSION.major, count=1)
env = replace(env, '#' => VERSION.minor, count=1)
env = replace(env, '#' => VERSION.patch, count=1)
name = env[2:end]
temp = name == "temp" ? true : false
# look for named env in each depot
for depot in DEPOT_PATH
path = joinpath(depot, "environments", name)
isdir(path) || continue
for proj in project_names
file = abspath(path, proj)
if isfile_casesensitive(file)
temp && @warn """
Activiating the pre-existing shared environment named `temp` at
$file."""
return file
end
end
end
isempty(DEPOT_PATH) && return nothing
temp && (return mktempdir()) || (return abspath(DEPOT_PATH[1], "environments", name, project_names[end]))
end
# otherwise, it's a path
path = abspath(env)
if isdir(path)
# directory with a project file?
for proj in project_names
file = joinpath(path, proj)
isfile_casesensitive(file) && return file
end
end
# package dir or path to project file
return path
end Please indicate with 👍 or 🚀. |
--project=--temp
--project=@temp
test/loading.jl
Outdated
@@ -683,7 +683,7 @@ end | |||
|
|||
# Base.active_project when version directory exist in depot, but contains no project file | |||
mktempdir() do dir | |||
vdir = Base.DEFAULT_LOAD_PATH[2] | |||
vdir = Base.DEFAULT_LOAD_PATH[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
I thought the Also, we really should check for an existing shared environment called |
base/initdefs.jl
Outdated
@@ -131,21 +132,23 @@ end | |||
# this will inherit an existing JULIA_LOAD_PATH value or if there is none, leave | |||
# a trailing empty entry in JULIA_LOAD_PATH which will be replaced with defaults. | |||
|
|||
const DEFAULT_LOAD_PATH = ["@", "@v#.#", "@stdlib"] | |||
const DEFAULT_LOAD_PATH = ["@", "@temp", "@v#.#", "@stdlib"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait. I thought @StefanKarpinski was saying that @oxinabox could set this in her startup.jl, but this is changing the default for everyone.
We do not want to change the default. That would be a breaking change.
#49061 FTW! |
f8e7121
to
75a85a6
Compare
The changes to Footnotes |
base/initdefs.jl
Outdated
startswith(project, "@") ? load_path_expand(project) : | ||
abspath(expanduser(project)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a formatting change? From a formatting perspective, I think indentation of line 242 would be useful.
From a soruce control perspective, I would prefer no change since this does not seem necessary for the feature being added
.
startswith(project, "@") ? load_path_expand(project) : | |
abspath(expanduser(project)) | |
startswith(project, "@") ? load_path_expand(project) : | |
abspath(expanduser(project)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indenting just the line 242 wouldn't do, considering previous 2 lines are also the else-options for ?:
But I agree, this change isn't necessary. I've reverted that here.
75a85a6
to
b203b09
Compare
Thank you for the changes. I think this is mergeable. I remain concerned about the unusual case where there does exist a shared environment called "temp" that people may have accessed via We should consider checking if such an environment exists and issuing a warning in that case. That said, it could be another pull request. |
Let's rebase and merge this. |
- Update relevant docs. - Add tests for `--project=@temp` and `JULIA_PROJECT="@temp"`. This makes it convenient to start and run Julia in a temporary environment. This brings `Pkg.activate(; temp=true)` functionality to cmdline.
This makes it convenient to start and run Julia in a temporary environment. This brings
Pkg.activate(; temp=true)
functionality to cmdline.--project=@temp
andJULIA_PROJECT="@temp"
.