# Invoking Julia from the Terminal on MacOS

**URL:** <https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 23, 2016, 9:48pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124 "2016-12-23T21:48:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vincent/32/380_2.png) [@vincent](https://discourse.julialang.org/u/vincent)\
**Post date:** [December 23, 2016, 9:48pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/1 "2016-12-23T21:48:35Z")

</div>

hi  
happy to found julia after long time of hesitations in the choice of a language to make animated graphicals mathematics  
now, i follow the instructions on  
[http://docs.julialang.org/en/stable/manual/getting-started/](http://docs.julialang.org/en/stable/manual/getting-started/)  
i type “julia” in a temrinal windows of my mac os X.10.4  
in the julia session i type : julia essai.jl  
answer :  
ERROR: UndefVarError: julia not defined  
i guess that something is wrong with the fact that i installed julia throught a dmg file while the use of julia in the termonal shoul have maybe needed a mor "deep "installation with the sources etc ?  
if anyone can help for this ultra-beggining question…  
thanks !

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 23, 2016, 10:00pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/2 "2016-12-23T22:00:50Z")

</div>

To invoke Julia in the Terminal, you need to make sure that the `julia` command-line program is in your PATH. On MacOS, I usually do this by creating a link in `/usr/local/bin`:

```nohighlight
sudo ln -s /Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia

```

(Assuming you have installed “Julia-0.5” into your Applications folder, as is typical.)

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [December 23, 2016, 10:17pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/3 "2016-12-23T22:17:25Z")

</div>

Also, the command in that doc is shell command used to run the script,not how you run a script once you’re in the julia REPL. To run a script in the REPL use `include("script_path.jl")`

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vincent/32/380_2.png) [@vincent](https://discourse.julialang.org/u/vincent)\
**Post date:** [December 23, 2016, 10:41pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/4 "2016-12-23T22:41:01Z")

</div>

> [@stevengj](#):
>
> sudo ln -s /Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia
> 
> (Assuming you have installed “Julia-0.5” into your Applications folder, as is typical.)

ok thank you both of you  
both work now :  
julia essai.jl from the terminal  
include(“essai.jl”) from the julia prompt  
i prefer the first method  
now i can start  
thanks

---

<div class="post-metadata">

**Author:** ![laut](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laut/32/15651_2.png) [@laut](https://discourse.julialang.org/u/laut)\
**Post date:** [September 3, 2020, 5:47pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/6 "2020-09-03T17:47:58Z")

</div>

Exactly what I needed. Thanks @stevengj

---

<div class="post-metadata">

**Author:** ![OldSubSailor](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@OldSubSailor](https://discourse.julialang.org/u/OldSubSailor)\
**Post date:** [April 20, 2023, 2:00pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/7 "2023-04-20T14:00:19Z")

</div>

New UPDATE  
I tried the command line above, by using the copy button on it. For some reason it would not work even after I edited it to the current version. I worked with the Apple Community and for some reason the same line with the current version now works:

sudo ln -s /Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia /usr/local/bin/Julia

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [April 20, 2023, 2:24pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/8 "2023-04-20T14:24:31Z")

</div>

Not sure I understand your second sentence, but in .zshrc I have:

```julia
alias j8="/Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia"
alias j9="/Applications/Julia-1.9.app/Contents/Resources/julia/bin/julia"
alias j="/Users/rob/Projects/Julia/julia/julia"

```

for Julia 1.8, Julia 1.9 and Julia 1.10 (after building the nightly version).

---

<div class="post-metadata">

**Author:** ![OldSubSailor](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@OldSubSailor](https://discourse.julialang.org/u/OldSubSailor)\
**Post date:** [April 20, 2023, 2:49pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/9 "2023-04-20T14:49:18Z")

</div>

How did you build the nightly version? I just installed the Homebrew version and it works from the command line (only).  
Did you create the Alais, which I don’t think is a result of the path command line?? f

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [April 20, 2023, 5:06pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/10 "2023-04-20T17:06:46Z")

</div>

In a terminal, clone the repository once (while cd-ed to e.g. `/Users/rob/Projects/Julia/ `. To update, in the directory of the download, e.g. `/Users/rob/Projects/Julia/julia`, run `git pull && make`.

Editors such as VSCode, TextMate, SublimeText, etc. usually require some additional settings to point to above locations.

The alias-es I think were were created (copied) when Apple switched to using zshell. Or I might have done it as in my .cshrc there are many lines to start Julia projects, e.g.:

```julia
alias srs8="cd ~/.julia/dev/SR2StanPluto; j8 -i -e 'using Pkg; pkg\"activate .\"'"
alias srs9="cd ~/.julia/dev/SR2StanPluto; j9 -i -e 'using Pkg; pkg\"activate .\"'"
alias srs="cd ~/.julia/dev/SR2StanPluto; j -i -e 'using Pkg; pkg\"activate .\"'"

```

---

<div class="post-metadata">

**Author:** ![OldSubSailor](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@OldSubSailor](https://discourse.julialang.org/u/OldSubSailor)\
**Post date:** [April 20, 2023, 5:36pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/11 "2023-04-20T17:36:41Z")

</div>

So the alias allows you to use the terminal. I take it that you just enter j8 or j9 in terminal to bring up Julia?

It was trying to use the path command line that I am not able to get to work now.  
sudo ln -s /Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia /usr/local/bin/Julia  
but now that I installed it via Homebrew it does not matter. I have to call it from the terminal. All that I am doing are the little Academy Courses.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [April 20, 2023, 5:56pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/12 "2023-04-20T17:56:36Z")

</div>

I expect Homebrew will make a `julia` command available to you from a location already in your path. That should suffice for usage from a Terminal.

---

<div class="post-metadata">

**Author:** ![OldSubSailor](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@OldSubSailor](https://discourse.julialang.org/u/OldSubSailor)\
**Post date:** [April 20, 2023, 6:42pm UTC](https://discourse.julialang.org/t/invoking-julia-from-the-terminal-on-macos/1124/13 "2023-04-20T18:42:57Z")

</div>

It did. However we discussed it on the Apple Support Community. I do not know why the one that I copied here did not work. The folks there wrote it again, using the current version and it did work from the terminal. So I deleted the Homebrew installation, and reinstalled the Julia org application along with the command line that was verified to work as of this morning. And it is all working now. Oh well, I did need to update a lot of Homebrew dependencies for my QGIS and Ortho4XPlane anyway.
