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
@nilshg Wow, yes, works perfectly. (I should have found that by googling, sorry)
Thanks, js
1 Like
Most Pkg
functions take an io
keyword argument that allows redirecting their output (or suppressing it by redirecting to devnull
):
$ julia -e 'import Pkg; Pkg.activate("/tmp", io=devnull); println("Hello!")'
Hello!
2 Likes
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 --project=~/myPackage -e 'using myPackage;RunMyCode()'
1 Like
I dont know how I missed that but is very logical. Thanks @ffevotte.
best, jd
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