Julia vs code extension reports opening package not part of my current envirionment

When a VS Code is opened with a project in the file explorer and a workbook is opened in a tab that comes from a different directory than the current project the extension reports You opened a Julia package that is not part of your current environment. Do you want to activate a different environment?

It’s very hard to understand this? Which package could it be? Which environment is the one that has the problem? Neither can be found easily.

Base.active_project() reports: "/Users/lewislevin/.julia/environments/@v1.12/Project.toml"

The project for the open folder in VS Code is: (test-notebooks as shown in terminal when running the package repl: ]. status for this folder shows that it is an empty Project.toml. well, of course its empty: there is no Project.toml in the directory at all.

At the root of the VS code file explorer, which is really the project folder, the Project.toml is:

name = "CovidSim_ilm"
uuid = "c70e2dfc-8e06-4fce-bc57-ad774aa1cb0a"
authors = ["Lewis Levin <lewis@neilson-levin.org>"]
repo = "https://github.com/lewisl/CovidSim_ilm.git"
version = "0.8.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
LazyTables = "3f3958f0-9dd7-4ba3-9331-125492819f7d"
NamedTupleTools = "d9ec5142-1e00-5aa0-9d6a-321866360f50"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PrettyPrint = "8162dcfd-2161-5ef2-ae6c-7681170c5f98"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
julia = ">= 1.7"

I am not an expert in how this aspect of Julia works, but this seems like there is no trouble.

My global environment is “@v1.12”. It’s project TOML is:

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
CovidSim_ilm = "c70e2dfc-8e06-4fce-bc57-ad774aa1cb0a"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
IndexedTables = "6deec6e2-d858-57c5-ab9b-e6ca5bd20e43"
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7"
LazyTables = "3f3958f0-9dd7-4ba3-9331-125492819f7d"
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
OhMyREPL = "5fb14364-9ced-5910-84b2-373655c76a03"
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PrettyPrint = "8162dcfd-2161-5ef2-ae6c-7681170c5f98"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[sources]
CovidSim_ilm = {path = "/Users/lewislevin/code/Covid Modeling/Covid-ILM"}

So, I am sort of at wit’s end with this. The currently open project in VS Code has no pinned packages. I have noticed that there can be a mismatch between the versions in the project manifest and the global environment package versions. The resolution for this seems to be to delete the manifest.toml file and let Julia recreate it, presumably with activate. I do this now as a matter of hygiene. But, not clear that will fix it.

I note that LazyTables seems to pin a dependency PrettyTables at version 2.4.0, and there is a newer PrettyTables. Not sure if this would be causing my problems.

I have tried to understand the documentation for Packages, but alas it is beyond me. So, many intricate cross dependencies. I wish there was a way to force the use only of the global environment. Multiple environments and pinned dependencies seem to be serious anti-patterns. My motto is one environment containing the latest versions of all packages. Use only the latest versions of packages for all projects. I would try not to have projects at all, but a package must be a project and a package is the best way to manage a complex set of Julia source files that are incorporate in one module.

With more recent versions of Julia this has become more challenging, at least to me.

Why do you want to open a project and a (different) workbook in the same instance of VSCode?

I would not do that. A workbook appears to be a separate project with its own Project.toml file. Can you explain a little bit more what you mean with workbook?

You can also open two instances of VSCode, if you need to work with two different projects at the same time.

1 Like

Sorry, I meant Jupyter notebook.

I moved most of my notebooks out of the development directory because they are not properly part of the project. A couple remain because they are designed to be useful for testing–though not automated testing.

I think I solved this problem. When the VS Code extension or Julia–not sure which–finds a usage of packages not int the environment the message appears in VS Code overlapping a side panel–that and its appearance make it seem like a VS Code error popup, so I think VS Code Julia extension generates it.

In any case, the fix was simple enough. Because of various of my screw-ups with environments, this was appearing a lot. the popup provides the opportunity to choose a different environment. I chose one and the extension puts it into the extension’s settings.

Well, that can be a bad idea because then that environment is sort of global for any use of the extension. Julia should pick the active environment based on its logic or the user (erstwhile programmer) should set it in code–if we can do that before the extension complains. The easy fix is blanking out the setting for path to environment.

Then Julia prevails and more than likely, does the right thing. And did in this case…