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

**URL:** <https://discourse.julialang.org/t/julia-fails-to-execute-shell-commands-breaks-download-package-installation-etc/6734>\
**Category:** General Usage\
**Created:** [October 28, 2017, 12:57am UTC](https://discourse.julialang.org/t/julia-fails-to-execute-shell-commands-breaks-download-package-installation-etc/6734 "2017-10-28T00:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulatf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dulatf/32/2356_2.png) [@dulatf](https://discourse.julialang.org/u/dulatf)\
**Post date:** [October 28, 2017, 12:57am UTC](https://discourse.julialang.org/t/julia-fails-to-execute-shell-commands-breaks-download-package-installation-etc/6734/1 "2017-10-28T00:57:59Z")

</div>

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:

```julia
run(`which curl`)
ERROR: could not spawn `which curl`: no such file or directory (ENOENT)
Stacktrace:
 [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?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [October 28, 2017, 1:50am UTC](https://discourse.julialang.org/t/julia-fails-to-execute-shell-commands-breaks-download-package-installation-etc/6734/2 "2017-10-28T01:50:08Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![dulatf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dulatf/32/2356_2.png) [@dulatf](https://discourse.julialang.org/u/dulatf)\
**Post date:** [October 30, 2017, 5:06pm UTC](https://discourse.julialang.org/t/julia-fails-to-execute-shell-commands-breaks-download-package-installation-etc/6734/3 "2017-10-30T17:06:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [August 26, 2018, 6:17pm UTC](https://discourse.julialang.org/t/julia-fails-to-execute-shell-commands-breaks-download-package-installation-etc/6734/4 "2018-08-26T18:17:07Z")

</div>

you can try [GitHub - innerlee/Shell.jl: Run shell commands becomes easy in Julia!](https://github.com/innerlee/Shell.jl) if you are using Julia 1.0

```julia
using Shell
Shell.run("which curl")

```
