WARNING: Base.Pkg is deprecated in 0.7 release

I just installed the released 0.7 on MacOS, and whenever I try to install packages, I see the message:

julia> Pkg.add("IJulia")
WARNING: Base.Pkg is deprecated, run `using Pkg` instead
 in module Main

Is this simply one of the deprecations I’ll need to deal with before upgrading to 1.0, or is something “wrong” with my installation?

1 Like

This is the old interface. Press ], then

pkg> add IJulia

Note that that is just complaining about the implicit import from Base. If you do using Pkg first, then Pkg.add will work as before (but use the new package manager). See - YouTube for more.

1 Like

How do I cd to the directory of a package in 0.7? cd(Pkg.dir(...)) is deprecated it seems.

https://github.com/JuliaLang/Pkg.jl/issues/417

TL;DR:

  1. you may not need it in most cases any more,
  2. use @__DIR__ in your module,
  3. Base.pathof(::Module) if you really need it.

Thanks!

Wait so what do I do when I want to open up Julia and make a change to a package? Normally i would do

cd(Pkg.dir("MyPackage"))
using Revise
using MyPackage
edit("MyPackage.jl")
... make edits 

you type dev MyPackage into the Pkg repl and it’ll get you a git clone of it into ~/.julia/dev/MyPackage. In particular, you should no longer edit packages in situ without deving them first, because the package manager is in charge of non-dev packages.

3 Likes

It will change my directory to the right place, then?

Thanks that’s exactly what I needed.

How to get out of this state ( pkg> ) on REPL?
And how to add a package in Jupyter with Julia v. 0.7?

How to get out of this state ( pkg> ) on REPL?

Backspace

And how to add a package in Jupyter with Julia v. 0.7?

You can still use the Pkg.add API (after a using Pkg). And there’s also a pkg"" string macro to execute Pkg REPL commands programatically.

2 Likes

In Jupyter I tried:

using Pkg
Pkg.add("Gadfly")
using Gadfly

And I got the following errors:

 ┌ Info: Precompiling Gadfly [c91e804a-d5a3-530f-b6f0-dfbca275c004]
└ @ Base loading.jl:1187
┌ Warning: Deprecated syntax `try without catch or finally` at /Users/sergiobacelar/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:971.
└ @ ~/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:971
┌ Warning: Deprecated syntax `try without catch or finally` at /Users/sergiobacelar/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:980.
└ @ ~/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:980
┌ Warning: Deprecated syntax `try without catch or finally` at /Users/sergiobacelar/.julia/packages/Compose/8DJMJ/src/Compose.jl:207.
└ @ ~/.julia/packages/Compose/8DJMJ/src/Compose.jl:207
WARNING: importing deprecated binding Base.Nullable into Compose.
ERROR: LoadError: LoadError: TypeError: in Type{...} expression, expected UnionAll, got typeof(Base.Nullable)
Stacktrace:
 [1] top-level scope at none:0
 [2] include at ./boot.jl:317 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1038
 [4] include at ./sysimg.jl:29 [inlined]
 [5] include(::String) at /Users/sergiobacelar/.julia/packages/Compose/8DJMJ/src/Compose.jl:3
 [6] top-level scope at none:0
 [7] include at ./boot.jl:317 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:1038
 [9] include(::Module, ::String) at ./sysimg.jl:29
 [10] top-level scope at none:2
 [11] eval at ./boot.jl:319 [inlined]
 [12] eval(::Expr) at ./client.jl:399
 [13] top-level scope at ./none:3
in expression starting at /Users/sergiobacelar/.julia/packages/Compose/8DJMJ/src/measure.jl:133
in expression starting at /Users/sergiobacelar/.julia/packages/Compose/8DJMJ/src/Compose.jl:69
ERROR: LoadError: Failed to precompile Compose [a81c6b42-2e10-5240-aca2-a61377ecd94b] to /Users/sergiobacelar/.julia/compiled/v0.7/Compose/sbiEw.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1185
 [4] _require(::Base.PkgId) at ./logging.jl:311
 [5] require(::Base.PkgId) at ./loading.jl:852
 [6] macro expansion at ./logging.jl:311 [inlined]
 [7] require(::Module, ::Symbol) at ./loading.jl:834
 [8] include at ./boot.jl:317 [inlined]
 [9] include_relative(::Module, ::String) at ./loading.jl:1038
 [10] include(::Module, ::String) at ./sysimg.jl:29
 [11] top-level scope at none:2
 [12] eval at ./boot.jl:319 [inlined]
 [13] eval(::Expr) at ./client.jl:399
 [14] top-level scope at ./none:3
in expression starting at /Users/sergiobacelar/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:7
Failed to precompile Gadfly [c91e804a-d5a3-530f-b6f0-dfbca275c004] to /Users/sergiobacelar/.julia/compiled/v0.7/Gadfly/DvECm.ji.

Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1185
 [4] macro expansion at ./logging.jl:311 [inlined]
 [5] _require(::Base.PkgId) at ./loading.jl:941
 [6] require(::Base.PkgId) at ./loading.jl:852
 [7] macro expansion at ./logging.jl:311 [inlined]
 [8] require(::Module, ::Symbol) at ./loading.jl:834

Well, you installed Gadfly successfully, it’s just not updated for 0.7 yet.

2 Likes

I can’t add any packages…

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

pkg> add PyPlot
ERROR: no active project
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] find_project_file(::Nothing) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:243
 [3] Pkg.Types.EnvCache(::Nothing) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:285 (repeats 2 times)
 [4] Type at ./none:0 [inlined]
 [5] Context!(::Array{Pair{Symbol,Any},1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:367
 [6] Context! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:497 [inlined]
 [7] do_add!(::Dict{Symbol,Any}, ::Array{Pkg.Types.PackageSpec,1}, ::Dict{Symbol,Any}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:633
 [8] #invokelatest#1(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:691
 [9] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:690
 [10] do_cmd!(::Pkg.REPLMode.PkgCommand, ::REPL.LineEditREPL) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:542
 [11] #do_cmd#30(::Bool, ::Function, ::REPL.LineEditREPL, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:507
 [12] do_cmd at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:503 [inlined]
 [13] (::getfield(Pkg.REPLMode, Symbol("##41#44")){REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:842
 [14] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [15] invokelatest at ./essentials.jl:690 [inlined]
 [16] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/LineEdit.jl:2261
 [17] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:1029
 [18] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:191
 [19] (::getfield(Base, Symbol("##831#833")){Bool,Bool,Bool,Bool})(::Module) at ./logging.jl:311
 [20] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [21] invokelatest at ./essentials.jl:690 [inlined]
 [22] macro expansion at ./logging.jl:308 [inlined]
 [23] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:340
 [24] exec_options(::Base.JLOptions) at ./client.jl:252
 [25] _start() at ./client.jl:432

The same command worked for me in MacOS x86_64-apple-darwin14.5.0.

You seem to have messed with DEPOT_PATH and/or LOAD_PATH. Whats the values of those?

JULIA_LOAD_PATH=.

i.e. set to the current directory.

edit: DEPOT_PATH is not set.

Okay. You either need to pkg> activate to get an environment, or instead append LOAD_PATH instead, i.e. JULIA_LOAD_PATH=.: (I think).