I just experienced the second occasion where I was trying to create a MWE for a bug report, but while creating the MWE I forgot that I was back in my @v1.4
environment rather than the environment in which I first encountered the error. It would be handy if there were a startup option that would print the currently active environment as part of the julia>
prompt so that you always know what environment you’re in.
I created a github issue for this the first time that I made that mistake. Give it some thumbs up if you support the change:
https://github.com/JuliaLang/julia/issues/35876
You can check that by just typing ]
to go to Pkg
mode I think?
Yeah, I know that. And yet I often forget to explicitly type ]
into the REPL to double check what environment I’m in. Without the explicit visual indication in the normal REPL prompt, it’s easy to subconsciously assume you’re in one environment when you’re actually in another. Especially if you’re changing environments or Julia sessions, it’s easy to lose track of what environment you’re in, and a subconscious assumption might take over.
4 Likes
The precedent is already there with Python environments:
Conda
bieganek@D20191947:~$ conda activate
(anaconda3) bieganek@D20191947:~$
venv
$ python3 -m venv myenv
$ source myenv/bin/activate
(myenv) $
@dalejordan Yes, I am the one who created that github issue. In case you didn’t realize, the answer given there was tongue-in-cheek. That’s not really meant to be a public API.
I think the answer there was in earnest. You can just put that snippet in your startup.jl
and have the desired behavior.
Not everyone has the same preferences for their prompt, so it is best to just keep it simple by default.
2 Likes
Putting
Base.active_repl.interface.modes[1].prompt =
() -> string(Pkg.REPLMode.promptf()[1:end-5], "julia> ")
in my startup file seems prone to breakage, since it seems to rely on internal implementation details that could change in a new release.
I’m not arguing that the default should be changed. I’m only arguing that there should be a public, easily accessible flag to turn on the display of the current environment in the julia>
prompt.
2 Likes