Run Julia from Mac terminal?

13,328 views
Skip to first unread message

Jason Pierce

unread,
Sep 20, 2013, 3:20:22 PM9/20/13
to julia...@googlegroups.com


Can I set up Julia to run directly from the terminal in Mac OS 10.8? I would like to execute a Julia file the same way I could for ruby: $ ruby file.rb.

I have downloaded and installed the Mac version of Julia. 

Thanks for the help.

Stefan Karpinski

unread,
Sep 20, 2013, 3:35:34 PM9/20/13
to Julia Users
`julia file.jl` should do it.
Message has been deleted

Jason Pierce

unread,
Sep 20, 2013, 3:44:10 PM9/20/13
to julia...@googlegroups.com
Stefan, 

I created a test file and got the following:

$ julia first.jl
-bash: julia: command not found

Alessandro "Jake" Andrioni

unread,
Sep 20, 2013, 3:54:30 PM9/20/13
to julia...@googlegroups.com
Add it to your PATH before, probably in .profile, but it's been some
time since I used bash.

Elliot Saba

unread,
Sep 20, 2013, 8:27:36 PM9/20/13
to julia...@googlegroups.com
If you're using the OSX binary, there are some environment variables that need to be set for Julia to run properly out of the .app container.  We have yet to automatically set these environment variables inside of Julia.

To see what needs to be set, (you could create a script file that sets these environment variables and then calls the Julia executable, and put that in your PATH) when you double-click on the .app file, it opens up a terminal and spits a bunch of text into it.  That bunch of text (minus the `exec` at the beginning) sets all the environment variables and invokes Julia.

I hope this helps, and if you have questions, please ask.
-E

Steven G. Johnson

unread,
Sep 21, 2013, 10:05:15 AM9/21/13
to julia...@googlegroups.com


On Friday, September 20, 2013 8:27:36 PM UTC-4, Elliot Saba wrote:
If you're using the OSX binary, there are some environment variables that need to be set for Julia to run properly out of the .app container.  We have yet to automatically set these environment variables inside of Julia.

It should be sufficient to add JULIA_HOME to your PATH.  e.g.

export PATH="/Applications/Julia-xxxxxxx.app/Contents/Resources/julia/bin:$PATH"

(replace "xxxxxxx" with whatever version you have).

This will give you both the "julia" command at the Terminal command line, and will also add Julia's git etc. to the path.

Ahmed Hassan-albanna

unread,
Feb 8, 2015, 9:09:37 AM2/8/15
to julia...@googlegroups.com
You can just create a symbolic link (not alias) by typing in terminal

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

or

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

(use only one command and the second if you don't like editing your main bin directory)

Ahmed Hassan-albanna

unread,
Feb 8, 2015, 9:27:29 AM2/8/15
to julia...@googlegroups.com
you can just type this in terminal 

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


to create a symbolic link for julia in /usr/bin

or else you can use

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

if you don't like editing your /usr/bin directory


jimshapiro

unread,
Feb 9, 2015, 5:39:47 PM2/9/15
to julia...@googlegroups.com
I made the soft link (to usr/bin/julia) and added the "magic" first line "#! /usr/bin/julia" to a program. The program, which is just a one line "Hello, World" test, now executes from the command line, but the results are followed by an error message (I am running Julia 0.3.5):

~/julia/learning>./test.jl
Hello, World
warning: stack corruption detected

signal (6): Abort trap: 6
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Abort trap: 6

Viral Shah

unread,
Feb 14, 2015, 4:24:11 AM2/14/15
to julia...@googlegroups.com
I just tried it out and it works fine. I used 0.3.4, but I don't think that should matter. Does double clicking the .app work fine otherwise? What version of OS X is this?

-viral

jimshapiro .

unread,
Feb 14, 2015, 9:24:56 AM2/14/15
to julia...@googlegroups.com
Found it! For the record, I am running OS X 10.10.2, but that's not the issue. I have been programming longer than almost anyone and you would think that I would have checked this out. My setup is a little different than most people's. I develop and run my programs from within my editor, Epsilon, which is an Emacs clone that runs almost everywhere. It's a nice setup and one that has never failed me, until now. I just opened a terminal window and ran a Julia program. This is what I got:

jimshapiro-2:number_theory jim$ ./integer_sqrt.jl

After 10 iterations the (Newton-Halley) approximate integer square root of 154404674067544 = 12425967 (Floor)

jimshapiro-2:number_theory jim$


just like it should be. Thanks for getting back to me and I'm sorry I didn't dig deeper before posting. I'll report this problem to the fellow who wrote my editor.


Best,

Jim


Reply all
Reply to author
Forward
0 new messages