ENV["PATH"] is different for REPL started through VS Code

If I start the REPL using VS Code (Julia: Start REPL), I get different results for ENV["PATH"] than if I start the REPL in any other way.

VS Code: Version 1.83.1
Julia: 1.9.3
OS: MacOS Sonoma 14.0

I am assuming it is a setting with the Julia extension in VS Code, but I can’t seem to find it.

What are the differences?

The main problem is that I don’t have access to some executables that I would expect.

From the REPL started in VS Code:

julia> ENV["PATH"]
"/usr/bin:/bin:/usr/sbin:/sbin"

From a REPL started in the terminal:

julia> ENV["PATH"]
"/Users/dylan/.juliaup/bin:/Users/dylan/opt/anaconda3/bin:/Users/dylan/opt/anaconda3/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/CMake.app/Contents/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Library/TeX/texbin"

Just as a follow-up here is an example.

REPL started through VS Code:

shell> lualatex -v
zsh:1: command not found: lualatex

REPL started in the terminal:

shell> lualatex -v
This is LuaHBTeX, Version 1.16.0 (TeX Live 2023)
Development id: 7567

Execute  'luahbtex --credits'  for credits and version details.

There is NO warranty. Redistribution of this software is covered by
the terms of the GNU General Public License, version 2 or (at your option)
any later version. For more information about these matters, see the file
named COPYING and the LuaTeX source.

LuaTeX is Copyright 2022 Taco Hoekwater and the LuaTeX Team.

I have a vague recollection when I used to use amac that of I used the Julia from the downloaded .dmg, it didn’t have access to my normal shell, but if I opened it from the terminal, I did.

There’s a vs code setting for how to launch Julia, maybe check to make sure that’s calling the one from juliaup?

How do you start VS Code? Do you use some kind of isolation, such as Flatpak or Snap?

Launch VSCode from the terminal, if you need it to inherit environment variables set in ~/.bash_profile or similar.

2 Likes

I have not used any special way of starting or installing VS Code.

So how do you start it then? (And how is it installed, etc.)

1 Like

Starting from the terminal produces the same results. That is, I still don’t have access to my default PATH

Sorry, I might be misunderstanding your question and I might be lacking the knowledge on what you are trying to get at. In the most basic sense, I downloaded Visual Studio Code from the website (https://code.visualstudio.com/). I selected the Mac Universal Stable Build. It comes as a zip, I unzip it and drag the app into the Applications folder on Mac. Then I just execute the .app when I want to start VS Code.

As mentioned by @skleinbo , I have also started it from the terminal using the code command.

1 Like

Additionally, when I use the integrated terminal inside VSCode, I am not experiencing the same issue. This seems to have something to do with launching the REPL with the Julia extension through VSCode.

1 Like

Yeah, applications like this launch in their own shell process and don’t have access to your user-specific stuff.

If you right click this app in Finder, then “explore contents” (or something like that), then look for the bin/julia file. Right click that, and then copy the path to that file.

Use that to launch Julia instead. It’s weird that vs code uses that to launch an external REPL, but not for the internal one though

3 Likes

I have the same issue, Weave.jl is not working from the REPL inside VSCode but works fine from the terminal. Did you figure out any workarounds (such as a way to change the path in Julia only when opened in VScode)?

I did not find a suitable workaround. I just changed my workflow for now.