# Can Pkg.activate("myPackage") be silent?

**URL:** <https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481>\
**Category:** General Usage\
**Created:** [May 27, 2023, 12:49pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481 "2023-05-27T12:49:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackStrauss](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Post date:** [May 27, 2023, 12:49pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/1 "2023-05-27T12:49:54Z")

</div>

Hello All

I have a silly little problem I can’t figure out. For internal reasons, I need to load my packages from a custom path with `Pkg.activate("~/myPackage")`. The thing is, we run it on the command line (here Julia 1.9 and `PrecompileTools` have been a life saver) but what is bugging us is the message it prints out. When we run  
`julia -e 'using Pkg;Pkg.activate("~/myPackage/"); using myPackage;RunMyCode()`  
it prints out  
`Activating project at `~/myPackage/myPackage`  
is there any way to surpress this message, or do the same in a way that runs the code silently?

I know this is silly, but it bothers people here.

Thanks, Jack

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 27, 2023, 1:03pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/2 "2023-05-27T13:03:25Z")

</div>

Maybe

> **[GitHub - JuliaIO/Suppressor.jl: Julia macros for suppressing and/or capturing...](https://github.com/JuliaIO/Suppressor.jl)**
>
> Julia macros for suppressing and/or capturing output (STDOUT), warnings (STDERR) or both streams at the same time. - GitHub - JuliaIO/Suppressor.jl: Julia macros for suppressing and/or capturing ou...

---

<div class="post-metadata">

**Author:** ![JackStrauss](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Post date:** [May 27, 2023, 1:07pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/3 "2023-05-27T13:07:25Z")

</div>

@nilshg Wow, yes, works perfectly. (I should have found that by googling, sorry)

Thanks, js

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [May 28, 2023, 5:03pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/4 "2023-05-28T17:03:55Z")

</div>

Most `Pkg` functions take an `io` keyword argument that allows redirecting their output (or suppressing it by redirecting to `devnull`):

```sh
$ julia -e 'import Pkg; Pkg.activate("/tmp", io=devnull); println("Hello!")'
Hello!

```

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [May 28, 2023, 5:52pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/5 "2023-05-28T17:52:47Z")

</div>

I think it’s unfortunate that `Pkg` API calls give these outputs; it should be enough to do that in `pkg` mode and with pkg-strings. In this particular case there’s an easy workaround though, use the `--project` flag:

```julia
julia --project=~/myPackage -e 'using myPackage;RunMyCode()'

```

---

<div class="post-metadata">

**Author:** ![JackStrauss](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Post date:** [May 28, 2023, 5:58pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/6 "2023-05-28T17:58:46Z")

</div>

> [@ffevotte](#):
>
> Most `Pkg` functions take an `io` keyword argument that allows redirecting their output

I dont know how I missed that but is very logical. Thanks @ffevotte.

best, jd

---

<div class="post-metadata">

**Author:** ![JackStrauss](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Post date:** [May 28, 2023, 6:04pm UTC](https://discourse.julialang.org/t/can-pkg-activate-mypackage-be-silent/99481/7 "2023-05-28T18:04:16Z")

</div>

> [@GunnarFarneback](#):
>
> In this particular case there’s an easy workaround though, use the `--project` flag:
> 
> ```julia
> 
> ```

Thanks @GunnarFarneback, another good solution, now for the command line. And since almost all my code is run this way, very nice. As to your general point, I agree.

js
