# Could not spawn setenv ...7z.exe

**URL:** <https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620>\
**Category:** General Usage\
**Tags:** windows\
**Created:** [May 6, 2022, 3:03pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620 "2022-05-06T15:03:31Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [May 6, 2022, 3:03pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/1 "2022-05-06T15:03:32Z")

</div>

I got a fancy new laptop, heavily administered by the IT dept…

When doing `up` or even just using VScode, the following error message pops up:

```julia
ERROR: IOError: could not spawn setenv(`'C:\Users\XX\AppData\Local\Programs\Julia-1.8\libexec\7z.exe' x 'C:\Users\XX\.julia\registries\General.tar.gz'
...

```

Solution: run as admin, but that is not very popular with the IT dept.

Guess: `7z.exe` is on some kind of black list.

Any hints, anyone?

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [May 6, 2022, 3:51pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/2 "2022-05-06T15:51:56Z")

</div>

There isn’t really anything we can say/help to diagnose this - that error can have a multitude of reasons, only one of which is related to permissions. I’d suggest talking to your IT department about what could cause this, if you’re otherwise able to run 7z.exe.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [May 6, 2022, 3:55pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/3 "2022-05-06T15:55:58Z")

</div>

Thanks. I merely wanted to ask if anyone else has bumped into this - and maybe knows a solution.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [May 6, 2022, 3:59pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/4 "2022-05-06T15:59:43Z")

</div>

Well one other guess I’d have is that your IT department restricted the directories where `.exe` can be started from - in which case, the solution would be to ask your IT department to allow the directory where those julia installed binaries are located as well.

---

<div class="post-metadata">

**Author:** ![pdetrempe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdetrempe/32/38815_2.png) [@pdetrempe](https://discourse.julialang.org/u/pdetrempe)\
**Post date:** [November 21, 2023, 5:42pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/5 "2023-11-21T17:42:43Z")

</div>

@Paul_Soderlind Any luck figuring this out (possibly with your IT department)?

I also just received a fancy new (heavily administered) laptop, and I’m having the same IOError as you received. Thanks!

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 21, 2023, 7:07pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/6 "2023-11-21T19:07:28Z")

</div>

Is there any chance that the heavily adminiswtered laptop allows for WSL2? Basically, we need some kind of trusted sandbox.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [November 21, 2023, 9:30pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/7 "2023-11-21T21:30:51Z")

</div>

Well, eventually the IT folks made an exception for Julia. (Now, please don’t ask me to tell you how I made that happen…)

---

<div class="post-metadata">

**Author:** ![repeterat](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@repeterat](https://discourse.julialang.org/u/repeterat)\
**Post date:** [November 21, 2023, 9:49pm UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/8 "2023-11-21T21:49:27Z")

</div>

I had this problem too. I found that the version of 7z.exe included with Julia is flagged as malware and blocked by Windows Security. Try running it from Explorer and see if you get an error message.

The solution was to replace 7z.exe (and 7z.dll whilst at it) with a newer version (23.01 currently). You can see the path in the error message, for me it was  
C:\Users\username\.julia\juliaup\julia-1.9.4+0.x64.w64.mingw32\libexec\julia\7z.exe

Not the nicest solution, but it did the trick.

---

<div class="post-metadata">

**Author:** ![pdetrempe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdetrempe/32/38815_2.png) [@pdetrempe](https://discourse.julialang.org/u/pdetrempe)\
**Post date:** [November 22, 2023, 12:34am UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/9 "2023-11-22T00:34:54Z")

</div>

Hmmm. Updated those .dll & .exe files doesn’t seem to have fixed the issue for me. Were there any rebuilding steps you had to take as well? Or just replacing the files worked fine?

---

<div class="post-metadata">

**Author:** ![pdetrempe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdetrempe/32/38815_2.png) [@pdetrempe](https://discourse.julialang.org/u/pdetrempe)\
**Post date:** [November 22, 2023, 12:39am UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/10 "2023-11-22T00:39:07Z")

</div>

Unfortunately no WSL allowed. Don’t know if it would help my use case either. I’m using [MATDaemon.jl](https://github.com/jondeuce/MATDaemon.jl) to spin up a julia server in the background of a MATLAB process, and I don’t think that workflow currently supports WSL.

---

<div class="post-metadata">

**Author:** ![pdetrempe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdetrempe/32/38815_2.png) [@pdetrempe](https://discourse.julialang.org/u/pdetrempe)\
**Post date:** [November 22, 2023, 12:45am UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/11 "2023-11-22T00:45:45Z")

</div>

With @repeterat 's fix not working for me. I think I’m seeing the same issue as described here:

> <https://github.com/dmolina/DaemonMode.jl/issues/56>
>
> While DaemonModes works at home on my provate computer, i get on my work compute…r in the office:
> 
> \`\`\`
> ERROR: LoadError: IOError: could not spawn setenv(... julia ... -Cnative ... -g1 -O0 --output-ji ...) operation not supported on socket (ENOTSUP)
> Stacktrace:
> \[1\] \_spawn\_primitive at .\\process.jl:128
> \[2\] #725 at .\\process.jl:139
> \[3\] setup\_stdios at .\\process.jl:223
> \[4\] \_spawn at .\\process.jl:138
> \[5\] \_spawn at .\\process.jl:166
> \[6\] #open#734 at .\\process.jl:397
> \[7\] open at .\\process.jl:366
> \`\`\`
> 
> Might this be related to anti virus software? I read something about this in web.
> 
> Connection to the DeamonMode server from client seems to be established.
> 
> EDIT:
> With Julia 1.9 alpha the error vanishes.

---

<div class="post-metadata">

**Author:** ![repeterat](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@repeterat](https://discourse.julialang.org/u/repeterat)\
**Post date:** [November 22, 2023, 10:08am UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/12 "2023-11-22T10:08:24Z")

</div>

Just replaced them. Running the included 7z.exe gave an error message saying it was blocked. Maybe this is not the case for you.

---

<div class="post-metadata">

**Author:** ![repeterat](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@repeterat](https://discourse.julialang.org/u/repeterat)\
**Post date:** [November 22, 2023, 10:08am UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/13 "2023-11-22T10:08:55Z")

</div>

The error code I got was EACCES, not ENOTSUP

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 22, 2023, 11:09am UTC](https://discourse.julialang.org/t/could-not-spawn-setenv-7z-exe/80620/14 "2023-11-22T11:09:06Z")

</div>

> [@Paul\_Soderlind](#):
>
> `ERROR: IOError: could not spawn setenv`

Since this is a known result of Julia trying to run 7z.exe, and a rather cryptic error maybe as a start it could be changed to:

`ERROR: IOError: could not run 7z.exe on behalf of Julia, likely because of strict IT dept. blocklisting, please then talk to your administrator about it.`

[Spawn was correct, could be kept, setenv part was a bit cryptic and confusing.]

As is people might blame Julia for not working, rather than putting the blame where it belongs, with the above amended error message.

> [@repeterat](#):
>
> The solution was to replace 7z.exe (and 7z.dll whilst at it) with a newer version (23.01 currently).

Interesting. That’s something that Julia could do too. I suppose what is being checked for is some checksum of the z7.exe (or its .dll) since you can’t rely on just the name to block (it could be renamed and run), but I suppose a later version will be blocked in later version of that draconian security measure.

I believe Julia also has a decompression capability, built in or in a .dll (independent of that .exe), at least for files, if not full .zip supporting directories.

Maybe Julia could use that instead? But we don’t want to risk just Julia itself being blocked… nor also implement our full 7z.exe clone…

I hope malware will not get started built with Julia, then julia.exe being risked blocked. This would be a potential problem for all languages, e.g. Python too, and compilers that can e.g. build 7z.exe…

It really seems rather arbitrary to stop decompression programs, rather than (e.g. certain .exe) files you get after decompressing a certain file.
