# Pkg not defined when building packages even though I did use pkg

**URL:** https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371
**Category:** General Usage
**Tags:** question
**Created:** [July 15, 2019, 6:47am UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371 "2019-07-15T06:47:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Alexandre\_Chen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexandre_chen/32/42725_2.png) [@Alexandre\_Chen](https://discourse.julialang.org/u/Alexandre_Chen)
#### Post date: [July 15, 2019, 6:47am UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/1 "2019-07-15T06:47:52Z")

</div>

See picture below

 ![30%20PM](https://global.discourse-cdn.com/julialang/original/3X/6/3/63e09004de769537b247dd02611c88038f4ef93c.jpeg)

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 15, 2019, 7:01am UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/2 "2019-07-15T07:01:46Z")

</div>

The error seems to be in the build code of PETSc2, not at the toplevel. You may want to look at its source code and the logfile.

(please post [quoted code/output](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530) in the future)

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [July 15, 2019, 7:11am UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/3 "2019-07-15T07:11:11Z")

</div>

Hi @Alexandre_Chen Backing up what @Tamas_Papp says - pay attention to the logs.  
I would say please look at the develop option in the package manager.  
This means that when you install a package a local copy of the source and all the build steps is created.  
You can run the build then look at the Julia code which does the build and the log outputs.  
I find that you can tinker around with the build.jl and see what happens - this can give you some big clues as to what is going wrong!

[https://docs.julialang.org/en/v1/stdlib/Pkg/index.html](https://docs.julialang.org/en/v1/stdlib/Pkg/index.html)

But say you are working on a project and you encounter a bug in one of your dependencies! How would you access the source? `Pkg` can help you out with `develop` :

```julia
(v1.1) pkg> develop --local Example

```

The `Example` package is now cloned to the `dev` subdirectory of your project directory. You can edit `Example` 's source and any changes you make will be visible to your project.

Once upstream `Example` has been patched, you can stop tracking the local clone. Do this with a `free` command:

```julia
(v1.1) pkg> free Example

```

Now you are back to using the version of `Example` in the registry.

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [July 15, 2019, 7:18am UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/4 "2019-07-15T07:18:02Z")

</div>

I get the same error when  
pkg\> add [GitHub - OptimalDesignLab/PETSc2.jl: Wrappers for PETSc](https://github.com/OptimalDesignLab/PETSc2.jl)

Julia 1.1.1 with Linux Fedora 30 OS  
Sorry but I don’t have time to do any more debugging this morning.

As an aside, on Fedora Linux I just got an error building the MPI.jl package.  
I did not have cmake installed - which is a surprise. As I remember, on Ubuntu systems you should install buildessential

Also as a complete surprise to myself, I installed openmpi and openmpi-devel on Fedora 30 and I now find that by default the HPC style ‘Modules’ environment is used.  
So before your run Julia module load mpi  
(you can of course put this in a .bashrc file)

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [July 15, 2019, 7:46am UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/5 "2019-07-15T07:46:45Z")

</div>

Note this in the build.jl script:  
Some alarm bells are sounding here - PkgFix repo is below.  
Perhaps it is no longer relevant with Julia 1.1.1 or some similar issue

> **[GitHub - OptimalDesignLab/PkgFix.jl: A wrapper over Julia's package manager](https://github.com/OptimalDesignLab/PkgFix.jl)**
>
> A wrapper over Julia's package manager

Note that PkgFix.jl has three branches - master upgrade\_0.5 and upgrade\_0.6

I have been trying to hack on the build.jl script to cut oit PkgFix and get the script to work with Julia v1.1.1.  
I would advise contacting Jared and seeing if there is a way to get PETSc2 running with v1.1.1

# install PkgFix if not present

if !isdir(joinpath(Pkg.dir(), “PkgFix”))  
Pkg.clone(“[GitHub - OptimalDesignLab/PkgFix.jl: A wrapper over Julia's package manager](https://github.com/OptimalDesignLab/PkgFix.jl.git)”)  
end  
start\_dir=pwd()  
cd(Pkg.dir(“PkgFix”))  
run(`git checkout upgrade_0.6`)  
cd(start\_dir)

using PkgFix

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [July 15, 2019, 2:31pm UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/6 "2019-07-15T14:31:30Z")

</div>

The package (`PETSc2`) is just not up to date with Julia 1.0.

---

<div class="post-metadata">

### Author: ![Alexandre\_Chen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexandre_chen/32/42725_2.png) [@Alexandre\_Chen](https://discourse.julialang.org/u/Alexandre_Chen)
#### Post date: [July 15, 2019, 5:03pm UTC](https://discourse.julialang.org/t/pkg-not-defined-when-building-packages-even-though-i-did-use-pkg/26371/7 "2019-07-15T17:03:55Z")

</div>

Thank you guys all for the help!
