# julia.additionalArgs -e (...) REPL not recognised

**URL:** <https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466>\
**Category:** VS Code\
**Tags:** question\
**Created:** [January 6, 2025, 12:49pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466 "2025-01-06T12:49:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [January 6, 2025, 12:49pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/1 "2025-01-06T12:49:36Z")

</div>

Hi,

When executing some code at REPL startup in VS Code by adding `"-e ..."` to `julia.additionalArgs` in `./.vscode/settings.json`, I noticed that _Ctrl+Enter_ / _Execute code in REPL_ does not work for a new REPL (where the code after `-e` is executed). Additionally, clicking on _Choose Current Module (Main)_ in the bottom-right corner of VS Code shows the message “_Setting a module requires an active REPL._”, indicating that the obtained REPL is not properly recognised.

> **MWE settings.json**
>
> ```json
> {
> "julia.additionalArgs": ["-e println(\"a\")"]
> }
> 
> ```

> **System info**
>
> - Julia (ran in the VS Code REPL, with the “a” print):
> 
> ```julia-repl
> a
> julia> versioninfo()
> Julia Version 1.11.2
> Commit 5e9a32e7af (2024-12-01 20:02 UTC)
> Build Info:
> Official https://julialang.org/ release
> Platform Info:
> OS: Windows (x86_64-w64-mingw32)
> CPU: 8 × Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
> WORD_SIZE: 64
> LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
> Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
> Environment:
> JULIA_NUM_THREADS = 8
> JULIA_EDITOR = code
> 
> ```
> 
> - VS Code:
> 
> ```julia
> Version: 1.96.2 (user setup)
> Commit: fabdb6a30b49f79a7aba0f2ad9df9b399473380f
> Date: 2024-12-19T10:22:47.216Z
> Electron: 32.2.6
> ElectronBuildId: 10629634
> Chromium: 128.0.6613.186
> Node.js: 20.18.1
> V8: 12.8.374.38-electron.0
> OS: Windows_NT x64 10.0.19045
> 
> ```
> 
> - VS Code Julia extension: v1.127.2

Is this expected behaviour, or a bug? Is there an easy fix?  
In all cases, what would in general be the preferred way to run a piece of code when starting a project-specific REPL? (More specifically, I want to `push!` to `LOAD_PATH` in order to add development-time dependencies (which I don’t want to place in the Base environment). My attempted approach was then similar to [Create an implicit environment with package directories - #16 by francis-gagnon](https://discourse.julialang.org/t/create-an-implicit-environment-with-package-directories/109207/16), but suffers from the issue described above.)

---

<div class="post-metadata">

**Author:** ![francis-gagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/francis-gagnon/32/50424_2.png) [@francis-gagnon](https://discourse.julialang.org/u/francis-gagnon)\
**Post date:** [January 6, 2025, 2:12pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/2 "2025-01-06T14:12:20Z")

</div>

Looks like a bug to me. You should raise an issue on [GitHub - julia-vscode/julia-vscode: Julia extension for Visual Studio Code](https://github.com/julia-vscode/julia-vscode).

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [January 6, 2025, 3:18pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/3 "2025-01-06T15:18:44Z")

</div>

> Is this expected behaviour, or a bug?

Expected behaviour. Only one of `-e` and a file can be supplied at any time (see below) and the extension needs to load Julia with an internal startup file.

```julia
❯ cat test.jl
println("file")

❯ julia -e 'println("cmd")' test.jl
cmd

❯ julia test.jl -e 'println("cmd")'
file

```

> (More specifically, I want to `push!` to `LOAD_PATH` in order to add development-time dependencies (which I don’t want to place in the Base environment

Consider using a normal environment for that. Generally, I’d caution against `LOAD_PATH` modifications.

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [January 6, 2025, 5:51pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/4 "2025-01-06T17:51:12Z")

</div>

Thank you both for your replies!

> [@pfitzseb](#):
>
> the extension needs to load Julia with an internal startup file

I see, it indeed needs to load `terminalserver.jl`. Barring some hacky `"-e (...); include(\".../terminalserver.jl\")"` solution, I guess `settings.json` is not the appropriate place to run some project-specific development startup code.

My issue is then indeed also more of a Julia design choice, rather than anything related to the VS code extension itself.

> [@pfitzseb](#):
>
> Consider using a normal environment for that. Generally, I’d caution against `LOAD_PATH` modifications.

To clarify, my idea was to have a basic project environment with the essential packages for running and testing the code, and then load a development environment on top of that, via environment stacking.  
I suppose I could add the development tools into the normal project environment, maybe under `[extras]`, though I still feel they shouldn’t be part of the environment proper. Anyway, I’ll stick with this approach for now, which also removes the need for running any startup code.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [January 6, 2025, 9:15pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/5 "2025-01-06T21:15:55Z")

</div>

FWIW, we _could_ make this work. You could also consider putting your code into startup.jl, which seems like a pretty appropriate place for it anyways.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 6, 2025, 11:39pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/6 "2025-01-06T23:39:35Z")

</div>

> [@eldee](#):
>
> (More specifically, I want to `push!` to `LOAD_PATH` in order to add development-time dependencies (which I don’t want to place in the Base environment).

One thing you could do to avoid modifying `LOAD_PATH` is to build a separate environment for development purposes (much like it is customary to have a separate environment to add doc-building-time dependencies such as `Documenter`).

The process to build such an environment could be something like:

1. create a folder for it (e.g. named `dev_env`),
2. `Pkg.activate` this folder, and
3. `Pkg.develop` your package and `Pkg.add` other development-time dependencies in it.

In VS Code, you can then choose the environment you want to work in: either the regular package environment containing only runtime dependencies, or the environment defined by `dev_env/Project.toml` and containing extra development-time deps.

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [January 7, 2025, 12:11pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/7 "2025-01-07T12:11:21Z")

</div>

That would indeed also work. But the downside is you have to maintain two overlapping (with regards to included packages) environments. I.e., suppose you want to remove a package which you no longer use, you need to remember to remove it from both envs (though I guess keeping it in the dev env is not an issue).

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [January 7, 2025, 12:23pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/8 "2025-01-07T12:23:29Z")

</div>

Such an approach (see also [Understanding the startup.jl file -- is there a environment-specific version? - #2 by c42f](https://discourse.julialang.org/t/understanding-the-startup-jl-file-is-there-a-environment-specific-version/77998/2)) could indeed work. Presumably there is also a way to check which terminal is being used, and if is the VS Code one you could then load development-specific startup code.

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [January 7, 2025, 12:36pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/9 "2025-01-07T12:36:20Z")

</div>

Yet another solution, closest to what I originally had in mind, would be to make use of the `-L` flag in Julia to load a specified file:

- Directory tree:

```julia
project/
├─ Project.toml (contains e.g. StaticArrays)
├─ Manifest.toml
├─ dev_env/
│ ├─ Project.toml (does not contain StaticArrays, but e.g. Cthulhu)
│ ├─ Manifest.toml
│ ├─ dev_startup.jl
├─ .vscode/
│ ├─ settings.json
...

```

- `dev_startup.jl`:

```julia
push!(LOAD_PATH, @ __DIR__ )

```

- `settings.json`:

```julia
{
    "julia.additionalArgs": [
        "-L",
        "${workspaceFolder}/dev_env/dev_startup.jl"
    ]
}

```

(In case you’re wondering: first the global `startup.jl` file is run, then `dev_startup.jl` and finally `terminalserver.jl`.)

This approach seems to work fine.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 7, 2025, 1:47pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/10 "2025-01-07T13:47:22Z")

</div>

> [@eldee](#):
>
> But the downside is you have to maintain two overlapping (with regards to included packages) environments

Not really: the dependencies of your package are automatically pulled into the `dev_env` environment (as indirect dependencies) when you `Pkg.dev` your package into it. So that:

- direct dependencies of your package are explicitly listed (only) in the “master” `Project.toml`
- additional development-time dependencies are listed (only) in `dev_env/Project.toml`.

So no redundancy here. There is also no need for you to remember to keep these two environments in sync: when you add (or remove) a dependency in the master environment, `Pkg` will ask you to re-`resolve` the `dev_env` environment to reflect these changes.

  

> [@eldee](#):
>
> Yet another solution, closest to what I originally had in mind, would be to make use of the `-L` flag

That’s a clever idea!

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [January 7, 2025, 3:31pm UTC](https://discourse.julialang.org/t/julia-additionalargs-e-repl-not-recognised/124466/11 "2025-01-07T15:31:12Z")

</div>

Ah, my bad. I seem to have misinterpreted the [documentation](https://pkgdocs.julialang.org/v1/api/#Pkg.develop) of `]?dev`, from which I did not gather that this is quite similar to `]add`. (Though this is explained more clearly elsewhere in the `Pkg.jl` [documentation](https://pkgdocs.julialang.org/v1/managing-packages/#developing), and in [Add vs dev at a local path](https://discourse.julialang.org/t/add-vs-dev-at-a-local-path/58150) .)

Using `dev` is then a very neat and elegant solution!
