# Shell Command to make environmental variables

**URL:** https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997
**Category:** General Usage
**Tags:** cmd
**Created:** [July 13, 2024, 1:06pm UTC](https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997 "2024-07-13T13:06:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![s-baumann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/s-baumann/32/5843_2.png) [@s-baumann](https://discourse.julialang.org/u/s-baumann)
#### Post date: [July 13, 2024, 1:06pm UTC](https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997/1 "2024-07-13T13:06:47Z")

</div>

I am on linux and trying to execute the following in a Julia REPL:

> run(`export JULIA_NUM_THREADS=4`)

I get the error ERROR: IOError: could not spawn `export JULIA_NUM_THREADS=4`: no such file or directory (ENOENT)

I can execute simpler commands like run(`ls -l`) successfully. I just can’t make environmental variables. This is really confusing as if I copy paste this into a terminal directly it does work. So it seems like this is a bug in Julia (or it is just really complicated to execute terminal commands in Julia).

---

<div class="post-metadata">

### Author: ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)
#### Post date: [July 13, 2024, 1:14pm UTC](https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997/2 "2024-07-13T13:14:37Z")

</div>

The julia `run` function executes programs. The shell command `export` is not a program, it’s a builtin shell command. If you want to start a shell from julia you can do it explicitly with e.g. `run(`/bin/bash -c "<some shell command>"`)`

> The command is never run with a shell. Instead, Julia parses the command syntax directly, appropriately interpolating variables and splitting on words as the shell would, respecting shell quoting syntax. The command is run as `julia`’s immediate child process, using `fork` and `exec` calls.

[https://docs.julialang.org/en/v1/manual/running-external-programs/](https://docs.julialang.org/en/v1/manual/running-external-programs/)

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [July 13, 2024, 1:20pm UTC](https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997/3 "2024-07-13T13:20:19Z")

</div>

That being said, changing the environment variables is done by writing to the `ENV` dictionary.

Either way, changing `JULIA_NUM_THREADS` in a running session won’t increase the number of running threads. You have to set that environment variable before you start julia (that also means outside `startup.jl`).
