# Cleaning unnecessary files after building Julia

**URL:** <https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [February 22, 2024, 11:28am UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571 "2024-02-22T11:28:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [February 22, 2024, 11:28am UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/1 "2024-02-22T11:28:22Z")

</div>

Hi,

I manage to build Julia from source.  
It seems that the outputs of the build are in a folder called “usr”. In that folder I can see that there are the default folder that comes with a “normal” Julia installation, i.e. bin etc include lib libexec…etc. However the size of that usr folder is quite huge compare to a normal Julia installation folder.

How can I remove all the u necessary files under “usr” which are not necessary for this local built of Julia to work properly?

Thank you in advance for your help.

---

<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:** [February 22, 2024, 12:16pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/2 "2024-02-22T12:16:25Z")

</div>

Have you tried `make install`?

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [February 22, 2024, 1:59pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/3 "2024-02-22T13:59:54Z")

</div>

Thank you @mkitti but it seems that only rebuild the sysimage for julia and other packages. It does not delete all the unnecessary files in the various folder under “usr” and that are not needed for Julia to work.

---

<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:** [February 22, 2024, 2:36pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/4 "2024-02-22T14:36:33Z")

</div>

Umm… my usual sequence is as follows

```julia
make clean
make -jN # N is the number kf parallel workers
make install DESTDIR=/path/to/target

```

`make install` should copy files to the `DESTDIR` you set.

Could you explain what you are trying to do? Are you trying to deploy an application or something?

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [February 22, 2024, 2:51pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/5 "2024-02-22T14:51:40Z")

</div>

No not trying to deploy anything. I am just trying to remove all the unnecessary files (which are taking a lot of space) after I have finished building Julia, so that what remains is only the files which are needed to have a properly working version of Julia. That is all 🙂

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [February 22, 2024, 2:55pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/6 "2024-02-22T14:55:33Z")

</div>

After doing your step 1 and 2, I already have a working version of Julia in the folder “usr”, I just need to get rid of everything that is not needed to run Julia.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 22, 2024, 3:13pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/7 "2024-02-22T15:13:22Z")

</div>

The thing is that `make install` will copy all necessary files to the given location. Afterwards, you can delete your entire build folder (i.e. the cloned julia repo).

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [February 22, 2024, 3:35pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/8 "2024-02-22T15:35:55Z")

</div>

Ok thanks, that command seems to rebuild the sysimage and then fails because julia tries to connect to internet…but the machine is not connected to internet… any idea how to finish this offline? Not sure why it needs to connect to internet because the julia version that i have in the folder “usr” is working properly…

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [April 22, 2024, 7:55am UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/9 "2024-04-22T07:55:02Z")

</div>

So after fiddling around with the build process for some times, here are my findings:

1/ building the doc part does not work at all for me, probably because I am behind a firewall/proxy, so I excluded the relevant instruction in the makefile. If anyone is interested in the error I get, I can copy it here.

2/ once the above issue taken care of, `make` and `make install` work fine and I am able to build a portable version of julia with just the necessary files.

3/ I noticed that `make` is not necessary and that you can skip that step and go straight to `make install -j N`. That will actually do a fine job, at least on windows!

4/ I don’t know if there are some redundant steps between `make` and `make install` . But I did the following and it made the `install` part so much quicker. I got rid of the line `@$(MAKE) $(QUIET_MAKE) $(JULIA_BUILD_MODE)` in the Makefile in for the `install` part. This might explain also why I don’t need to do a `make` and a `make install` , and that a `make install` is enough.

Any feedback on the above is welcome. Thank you.

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [April 22, 2024, 1:32pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/10 "2024-04-22T13:32:48Z")

</div>

When installing julia on computers not on the internet, I’ve done a

```julia
$ make full-source-dist

```

on an internet connected machine. It produces a tarball which can be untared and used to build julia off internet.

---

<div class="post-metadata">

**Author:** ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Post date:** [April 23, 2024, 2:27pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/11 "2024-04-23T14:27:56Z")

</div>

The only outstanding question I have is:  
Is it intentional that `make` and `make install` both build Julia from scratch, i.e. there are some duplicated steps ?  
`make install` also build other things like the documentation and a portable version of Julia which `make` does not do…  
Or maybe I just did not understand at all what is intended …

---

<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:** [April 23, 2024, 7:07pm UTC](https://discourse.julialang.org/t/cleaning-unnecessary-files-after-building-julia/110571/12 "2024-04-23T19:07:45Z")

</div>

The make files declare a set of dependencies for various targets. The install target depends on building everything else, so yes this is expected that `make install` will build everything AND then install it to the destination.
