Julia: On my Mac mini, when I open a terminal, I can not use Julia from the Unix command line

Created on 19 Oct 2014  路  17Comments  路  Source: JuliaLang/julia

I installed Julia v0.3.1 on my Mac mini.
I can start and use Julia in interactive mode, but
I can not run code in a file non-interactively.
If at Unix shell i type $ julia script.jl arg1 arg2...
I get
-bash: julia: command not found
Maybe I need to edit my .bash_profile:
and put in it a line:
export PATH="/Applications/Julia-0.3.1.app/Contents/MacOS:$PATH"
???????

build doc help wanted mac

Most helpful comment

You probably want to call /Applications/Julia-0.3.1.app/Contents/Resources/julia/bin/julia instead, as this won't open a new window. You can add this directory to your path, or a better solution is to symlink it into an appropriate directory (/usr/local/bin/ is typically used for this purpose):

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

(you might need to prefix this with sudo if you haven't installed Homebrew).

All 17 comments

You probably want to call /Applications/Julia-0.3.1.app/Contents/Resources/julia/bin/julia instead, as this won't open a new window. You can add this directory to your path, or a better solution is to symlink it into an appropriate directory (/usr/local/bin/ is typically used for this purpose):

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

(you might need to prefix this with sudo if you haven't installed Homebrew).

Just to be completely specific, Simon is suggesting you add /Applications/Julia-0.3.1.app/Contents/Resources/julia/bin to your PATH, e.g.

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

OR, you can symlink the julia executable into a directory that is already on your PATH, e.g.:

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

could this fit into the install documentation somewhere? This seems a standard and very useful thing to do!

Would it be possible to add a little program inside the dmg to do this (called, say, "Install command line")?

Some AppleScript like this seems to work, and gives a nice password prompt:

do shell script "ln -s /Applications/Julia-0.3.1.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia" with administrator privileges

Probably want to check the file exists first, but that exceeds the extent of my AppleScript knowledge.

Happy to give this a stab if it's still an issue, but cannot self-assign. @simonbyrne

@chrisvoncsefalvay I don't think that non-members of the JuliaLang organization can be assigned via the Github interface. I'll just assign it to myself by proxy, and we can work on it together along with @simonbyrne if he has time at the moment. This should be a fairly simple change, although I'd like to see an addition to Simon's code snippet to handle the case where /usr/local/bin/julia already exists.

Sounds great, thanks @staticfloat!

@staticfloat The code is now here - I'll leave it to you to figure out how to integrate it. It checks for the existence of an existing Julia executable in usr/local/bin/julia using a try/catch, so it will ask for your password first, whether usr/local/bin/julia exists or not - this is more or less unavoidable. I hope it's not a huge issue ;)

@simonbyrne I don't think the app installer should auto-install links outside the .app folder. However, this does come up often, and perhaps it can be in the intsallation notes that are shown in the install procedure, and a small README that is included in the dmg.

@ViralBShah That was why I proposed the separate script inside the .dmg, similar to what Mathematica does for its various plugins:
Mathematics install

Ah, I realise I misunderstood you. I see we are saying the same thing.

Actually, a better way might be to add files to /etc/paths.d/ and /etc/manpaths.d/, as that won't require overwriting anything. The only problem is that these are added to PATH in the order they appear, so that would mean older versions have precedence.

I think that the simplest thing to do for now is to document this. If you are going to call julia from the command line, you can easily add something to the PATH.

Also, you can find the installed path of a particular version of the Julia .app by:

mdfind "kMDItemCFBundleIdentifier == 'org.julialang' && kMDItemVersion == '0.4.2'"

Still not work in 2017.

Maybe it would be better to distribute it via brew? Need to download an app adds a barrier to Julia adoption. To my understanding Julia is not different from Ruby or Python and it rises an alarm when instead it suggest you to download some app and start a console in a funny way.

brew cask install julia already works

version 1.1, using this command can work

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

Was this page helpful?
0 / 5 - 0 ratings