a=string(Pkg.status()) > "nothing". How to get and save Pkg.status())?

Julia 0.7.0

How to get and save Pkg.status()) ?

julia> using Pkg

julia> a=string(Pkg.status())
    Status `C:\Users\PC\.julia\environments\v0.7\Project.toml`
  [686f71d1] ASDF v1.0.3
  [f9309374] ApplicationBuilder v0.3.1
  [eaca7b4f] BuildExecutable v0.1.2
  [336ed68f] CSV v0.4.3
  [a93c6f00] DataFrames v0.17.1 ?
  [e7dc6d0d] DataValues v0.4.7
  [31c24e10] Distributions v0.20.0
  [89b67f3b] ExcelFiles v0.9.1
  [5789e2e9] FileIO v1.0.6
  [4c0ca9eb] Gtk v0.17.0
  [f67ccb44] HDF5 v0.11.1
  [82899510] IteratorInterfaceExtensions v0.1.1
  [4138dd39] JLD v0.9.1
  [033835bb] JLD2 v0.1.2
  [49dea1ee] Nettle v0.4.0 ?
  [91a5bcdd] Plots v0.19.3
  [27ebfcd6] Primes v0.4.0
  [d71aba96] ReadStat v0.4.1 ?
  [c35d69d1] SMTPClient v0.3.1
  [1463e38c] StatFiles v0.8.0 ?
  [2913bbd2] StatsBase v0.30.0 ?
  [3783bdb8] TableTraits v0.4.1
  [a759f4b9] TimerOutputs v0.5.0
  [c17dfb99] WinRPM v0.4.2
  [bd07be1c] Winston v0.15.0
  [fdbf4ff8] XLSX v0.4.7 ?
  [9a3f8284] Random
"nothing"

See https://github.com/JuliaLang/Pkg.jl/pull/1053. But what’s the purpose? If you want to record the environment you should just store the Project.toml and Manifest.toml files, which is much more complete.

1 Like

For example, I want to send a list of my version packages to someone.

Paul

W dniu 2019-05-24 o 15:54, Fredrik Ekre via JuliaLang pisze:

You should just send Project.toml and Manifest.toml. It contains everything.

2 Likes

Hi, I understand this thread is referring to “Basically just add an io field to Context, thread the Context object through a more functions, and make the display stuff use the io field by default.” However, would it be possible to include here the code snippet that is doing this, I mean that is printing the output of Pkg.status() to a text file?

My logging to txt file setup currently:

using Logging
# Open a textfile for writing
io = open("log.txt", "w+")
IOStream("file log.txt")
# Create a simple logger
logger = SimpleLogger(io)
# Set the global logger to logger
global_logger(logger)
# Example of command output printed to log.txt
@info "Sys.CPU_NAME" Sys.CPU_NAME
# Close the file
close(io)

I understand that to reproduce the environment its better to use Project.toml and Manifest.toml files, however, I am doing some benchmarks and my purpose is just to note the version of packages, thus printing the output of Pkg.status() would be useful. And when trying @info Pkg.status() I am receiving nothing, thus this question.

EDIT: I think I got it:

Pkg.status(; io)