Julia fails to execute shell commands - breaks download(), package installation etc


I was trying to install some packages through the Julia package manager which seemed to fail because Julia was unable to locate curl (which is installed on my system).
I was able to trace the problem to the download() function and through there to the inability of Julia to execute the shell builtin ‘which’ with spawn().
Eg. this fails:

run(`which curl`)
ERROR: could not spawn `which curl`: no such file or directory (ENOENT)
 [1] _jl_spawn(::String, ::Array{String,1}, ::Ptr{Void}, ::Base.Process, ::RawFD, ::RawFD, ::RawFD) at ./process.jl:360
 [2] #373 at ./process.jl:512 [inlined]
 [3] setup_stdio(::Base.##373#374{Cmd}, ::Tuple{RawFD,RawFD,RawFD}) at ./process.jl:499
 [4] #spawn#372(::Nullable{Base.ProcessChain}, ::Function, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}) at ./process.jl:511
 [5] run(::Cmd) at ./process.jl:650
 [6] macro expansion at ./REPL.jl:97 [inlined]
 [7] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

Other shell builtins like ls or pwd seem to work just fine.
Interestingly, if I switch the Julia repl to shell mode by typing ‘;’, I can execute ‘which’ without any problems.

Interestingly, when I execute /bin/sh -c “which curl” on my regular shell that works just fine.

Any ideas how to fix this?


FWIW, run(`which curl`) works just fine on both OSX and Ubuntu for me, returning /usr/bin/curl in both cases (Julia 0.6.0).


Thank you for your response, I suppose I should rephrase the question a little.
Does anybody know how spawn() executes shell commands? It seems like it does not just run something like $SHELL -c ‘…’ internally, because that would work in my case.