# Pkg.init() Segmentation Fault

**URL:** https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112
**Category:** General Usage
**Tags:** question
**Created:** [May 23, 2018, 9:36pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112 "2018-05-23T21:36:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mkschleg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkschleg/32/8035_2.png) [@mkschleg](https://discourse.julialang.org/u/mkschleg)
#### Post date: [May 23, 2018, 9:36pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/1 "2018-05-23T21:36:52Z")

</div>

I’ve been looking around the issues on Github and the discussion here and haven’t found a solution to my problem. A few things. I’m behind a corporate proxy and on ubuntu-16.04. I’ve downloaded the precompiled version of Julia 0.6.2 but get some weird behavior when trying to add packages or even run Pkg.init().

Using the julia executable:

```julia
julia> Pkg.init()
INFO: Initializing package repository /home/matthew/.julia/v0.6

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
_IO_new_file_fopen at /build/glibc-Cl5G7W/glibc-2.23/libio/fileops.c:260
__fopen_internal at /build/glibc-Cl5G7W/glibc-2.23/libio/iofopen.c:86
fopen64 at /lib/libachk.so (unknown line)
cd at ./file.jl:66
Allocations: 1055791 (Pool: 1054681; Big: 1110); GC: 0
[1] 15679 segmentation fault (core dumped) ./julia

```

and the julia-debug executable

```julia
julia> Pkg.init()
INFO: Initializing package repository /home/matthew/.julia/v0.6
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
ERROR: SystemError: fchdir: Not a directory
Stacktrace:
 [1] #systemerror#44 at ./error.jl:64 [inlined]
 [2] systemerror(::Symbol, ::Bool) at ./error.jl:64
 [3] cd(::Base.Pkg.Dir.##8#10{String,String}, ::String) at ./file.jl:72
 [4] init(::String, ::String) at ./pkg/dir.jl:53
 [5] init() at ./pkg/pkg.jl:85

```

Because it isn’t throwing me errors about not being able to access the internet I don’t think it is my proxy settings (ENV[“HTTP\_PROXY”] and ENV[“HTTPS\_PROXY”] are set correctly). Has anyone faced a similar issue? I’m a bit stumped at this point.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [May 24, 2018, 4:05am UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/2 "2018-05-24T04:05:49Z")

</div>

Hm, very strange indeed. Is there something special about your home directory? Is it a network mount or anything other than just a regular folder on disk?

---

<div class="post-metadata">

### Author: ![mkschleg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkschleg/32/8035_2.png) [@mkschleg](https://discourse.julialang.org/u/mkschleg)
#### Post date: [May 24, 2018, 3:31pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/3 "2018-05-24T15:31:50Z")

</div>

No, the proxys are the only “out of the norm” part of my setup from what I can tell.

---

<div class="post-metadata">

### Author: ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)
#### Post date: [May 24, 2018, 9:43pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/4 "2018-05-24T21:43:07Z")

</div>

You could experiment with setting `JULIA_PKGDIR` environment variable to confirm there’s nothing funky going on with your home directory.

---

<div class="post-metadata">

### Author: ![mkschleg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkschleg/32/8035_2.png) [@mkschleg](https://discourse.julialang.org/u/mkschleg)
#### Post date: [May 24, 2018, 10:13pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/5 "2018-05-24T22:13:26Z")

</div>

Thanks for the suggestion, Same error though ☹.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [May 25, 2018, 2:52am UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/6 "2018-05-25T02:52:01Z")

</div>

Dang. Well, if it were me, this would be the part where I start trying some old-school debugging. The line where you’re getting the failure is in the call to `cd()` here: [https://github.com/JuliaLang/julia/blob/d386e40c17d43b79fc89d3e579fc04547241787c/base/pkg/dir.jl#L53](https://github.com/JuliaLang/julia/blob/d386e40c17d43b79fc89d3e579fc04547241787c/base/pkg/dir.jl#L53) (you can find this source file in `share/julia/base/pkg/dir.jl` in wherever you unpacked the Julia release).

Editing that file won’t take effect unless you rebuild julia’s pre-compiled system image, but you should be able to replicate what it’s doing. It looks like it’s doing, roughly:

```julia
dir = Pkg.Dir.path()
mkpath(dir)
temp_dir = mktempdir(dir)
cd(temp_dir)

```

and you should be able to run those steps from the command line. If you get the segfault, then at least you’re closer to understanding the problem and we can debug more. If not, then it might be something inside that `do` block that starts on the same line.

---

<div class="post-metadata">

### Author: ![mkschleg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkschleg/32/8035_2.png) [@mkschleg](https://discourse.julialang.org/u/mkschleg)
#### Post date: [May 25, 2018, 2:23pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112/7 "2018-05-25T14:23:06Z")

</div>

Great. Thanks for the help. This was really helpful! After looking through some of the code in dir.jl and running it via the interpreter it seems like this is indeed a Certificate verification error, but was for some reason hiding behind another bug. My guess is it failed to clone and the current code somehow ignored the git error and moved on to do something with the assumed downloaded code.

At any rate this is a much more manageable issue than the errors I was getting before. Thanks again for your help!
