# From Julia Doc - 5. Creating Package - Pkg not found after Activating?

**URL:** <https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067>\
**Category:** New to Julia\
**Tags:** packages, workflow\
**Created:** [December 26, 2023, 6:45pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067 "2023-12-26T18:45:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![benslinux](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Post date:** [December 26, 2023, 6:45pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/1 "2023-12-26T18:45:17Z")

</div>

Sometimes I generate a pkg, then activate, then import and it works fine. Other times I get the msg - pkg not found and it’s right there in the directory I’m in. It’s such a simple process, I don’t understand what’s changing. Do I need to instantiate each time? Also, if I install a package - ie - Plots or IJulia, they go into ‘packages’ folder in .julia - yet when I create a HelloWorld pkg to learn the process, I’m just choosing my home folder to create the project in. Is this maybe a local / global environment issue? I used snap to install julia – classic (Linux Mint) - maybe that’s interfering?

---

<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:** [December 26, 2023, 7:19pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/2 "2023-12-26T19:19:16Z")

</div>

See Revise.jl

---

<div class="post-metadata">

**Author:** ![benslinux](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Post date:** [December 26, 2023, 9:15pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/4 "2023-12-26T21:15:17Z")

</div>

Lost interest . . .

---

<div class="post-metadata">

**Author:** ![benslinux](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Post date:** [December 30, 2023, 12:06pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/5 "2023-12-30T12:06:47Z")

</div>

Try the following method (you can ignore Revise.jl for now). Since you use Linux, create project in your home directory (if necessary - type semicolon for shell\> to check which directory you’re in) - also pkg\>status is useful.

Creating a Pkg – Julia

julia\>

(@v1.9) pkg\> generate HelloWorld  
Generating project HelloWorld: HelloWorld/Project.toml  
HelloWorld/src/HelloWorld.jl

(@v1.9) pkg\> activate . Activating project at `~`

julia\> using Revise

(HelloWorld) pkg\> status  
Project HelloWorld v0.1.0  
Status `~/HelloWorld/Project.toml` (empty project)

(HelloWorld) pkg\> switch to Julia REPL

julia\> include(“HelloWorld/src/HelloWorld.jl”)

julia\> HelloWorld.greet() Hello World! Julia\>

_(Edit: You should be able to use: pkg\> activate ./HelloWorld and then import HelloWorld and have it work. If it doesn’t precompile, try the above method.)_

---

<div class="post-metadata">

**Author:** ![benslinux](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Post date:** [December 30, 2023, 1:41pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/6 "2023-12-30T13:41:49Z")

</div>

Thanks - it worked. Instead of just ( activate . ) I was using activate ~./HelloWorld, which should work, but I’d get an error msg that it couldn’t find the pkg. Also, I was adding ‘using HelloWorld’ in there which I guess is unnecessary and seemed to cause the same problem. Thanks again.

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [December 31, 2023, 11:57am UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/7 "2023-12-31T11:57:47Z")

</div>

I think part of the problem is typing

```julia
activate ~./HelloWorld

```

Julia won’t understand `~`, which is something that would be interpreted by a (Unix/Linux) shell. Julia is clever, but not that clever.

(It might be a copy/paste mistake, but even if Julia understood `~`, you probably mean `~/HelloWorld`, not `~./HelloWorld`)

---

<div class="post-metadata">

**Author:** ![benslinux](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Post date:** [December 31, 2023, 2:50pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/8 "2023-12-31T14:50:17Z")

</div>

@magister-ludi  
And it’s an easy mistake to make -

from the Julia documentation:  
We can now activate the project by using the path to the directory where it is installed, and load the package:

```julia
pkg> activate ./HelloWorld

```

A Linux user is always using that tilde. (~/) is the beginning of a path to a file or directory below the user’s home directory. If you’re creating the new Julia pkg in your home directory, it’s easy to mix the two syntaxes and mistakenly type that tilde on the front - though it doesn’t belong there.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [December 31, 2023, 6:36pm UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/9 "2023-12-31T18:36:20Z")

</div>

> [@benslinux](#):
>
> Since one tends to create the new package in the home dir, it’s easy to mix the two syntaxes and mistakenly type that tilde on the front

I almost never put things in the home directory. I have a `~/Repos` directory that I put anything development related.

One other thing to note is that, while the pkg repl understands the ~ shortcut, actual code will not. You’d need to do `expanduser("~/")`

---

<div class="post-metadata">

**Author:** ![benslinux](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Post date:** [January 2, 2024, 9:23am UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067/10 "2024-01-02T09:23:11Z")

</div>

You’re right, of course - It makes sense to create a new directory for storing real pkgs that are going to be used and developed. In my case, I’m just learning the commands for this pkg build process as part of learning Julia. Since my terminal always wakes in home directory, it just saves me a step.
