# Recover status of a package from julia

**URL:** <https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197>\
**Category:** General Usage\
**Created:** [September 24, 2020, 9:44am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197 "2020-09-24T09:44:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [September 24, 2020, 9:44am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/1 "2020-09-24T09:44:16Z")

</div>

Hi,  
I would like to recover a string containing the status of a given package (v.2.2.2 in the example) but I am only able to print it out

```julia
julia> Pkg.status("CuArrays")
Project BTL v0.1.0
Status `~/Project/BTL.jl/Project.toml`
  [3a865a2d] CuArrays v2.2.2

```

Is there a simple way to do it ?

---

<div class="post-metadata">

**Author:** ![JLDC](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jldc/32/17627_2.png) [@JLDC](https://discourse.julialang.org/u/JLDC)\
**Post date:** [September 24, 2020, 10:05am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/2 "2020-09-24T10:05:07Z")

</div>

Hi!

Would something along those lines work for you?

```nohighlight
original_stdout = stdout
(rd, wr) = redirect_stdout()
Pkg.status("CuArrays")
s = readline(rd)
redirect_stdout(original_stdout)
println(s)

```

See: [In Julia 1.0+: How do I get strings using redirect\_stdout - Stack Overflow](https://stackoverflow.com/questions/54599148/in-julia-1-0-how-do-i-get-strings-using-redirect-stdout)

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [September 24, 2020, 10:07am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/3 "2020-09-24T10:07:40Z")

</div>

Thanks a lot, this will do.  
I was wondering if I missed some obvious solution.

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [September 24, 2020, 11:22am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/4 "2020-09-24T11:22:49Z")

</div>

Actually this only returns the first line.  
I wonder why there is no IO first argument as it is often the case with Julia functions.

---

<div class="post-metadata">

**Author:** ![JLDC](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jldc/32/17627_2.png) [@JLDC](https://discourse.julialang.org/u/JLDC)\
**Post date:** [September 24, 2020, 11:31am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/5 "2020-09-24T11:31:28Z")

</div>

In that case you can just use `readlines(rd)` to get an array of strings.

But after a bit of tinkering around, I think this here suits you better than my solution above:

```julia
io = IOBuffer(read=true, write=true)
Pkg.status("CuArrays", io=io)
s = String(take!(io))
println(s)

```

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [September 24, 2020, 11:35am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/6 "2020-09-24T11:35:02Z")

</div>

Yes, much nicer !

I wonder why the help does not mention the io argument

```julia
help?> Pkg.status
  Pkg.status([pkgs...]; mode::PackageMode=PKGMODE_PROJECT, diff::Bool=false)
...

```

Than you again !

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [September 24, 2020, 11:57am UTC](https://discourse.julialang.org/t/recover-status-of-a-package-from-julia/47197/7 "2020-09-24T11:57:59Z")

</div>

> [@LaurentPlagne](#):
>
> I wonder why the help does not mention the io argument

[https://julialang.github.io/Pkg.jl/v1/api/#Redirecting-output-1](https://julialang.github.io/Pkg.jl/v1/api/#Redirecting-output-1)

It is something general, not only for `status()`
