Error with Pkg with using statement in startup.jl

I have a using statement in my startup.jl file (using OhMyREPL), and upon building packages, I get the following warnings

  Building LibCURL ─→ `C:\Users\Jeremy\.julia\packages\LibCURL\yT2TD\deps\build.log`
┌ Error: Error building `LibCURL`:
│ ERROR: LoadError: ArgumentError: Package OhMyREPL not found in current path:
│ - Run `Pkg.add("OhMyREPL")` to install the OhMyREPL package.
│
│ Stacktrace:
│  [1] require(::Module, ::Symbol) at .\loading.jl:817
│  [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_ifexists at .\client.jl:201 [inlined]
│  [6] load_julia_startup() at .\client.jl:298
│  [7] exec_options(::Base.JLOptions) at .\logging.jl:312
│  [8] _start() at .\client.jl:432
│ in expression starting at C:\Users\Jeremy\.julia\config\startup.jl:4
└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Pkg\src\Operations.jl:1068
  Building WinRPM ──→ `C:\Users\Jeremy\.julia\packages\WinRPM\0uTA1\deps\build.log`
┌ Error: Error building `WinRPM`:
│ ERROR: LoadError: ArgumentError: Package OhMyREPL not found in current path:
│ - Run `Pkg.add("OhMyREPL")` to install the OhMyREPL package.
│
│ Stacktrace:
│  [1] require(::Module, ::Symbol) at .\loading.jl:817
│  [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_ifexists at .\client.jl:201 [inlined]
│  [6] load_julia_startup() at .\client.jl:298
│  [7] exec_options(::Base.JLOptions) at .\logging.jl:312
│  [8] _start() at .\client.jl:432
│ in expression starting at C:\Users\Jeremy\.julia\config\startup.jl:4
└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Pkg\src\Operations.jl:1068
  Building Homebrew → `C:\Users\Jeremy\.julia\packages\Homebrew\Byw6Y\deps\build.log`
┌ Error: Error building `Homebrew`:
...

Obviously, OhMyREPL is properly installed and otherwise works fine.

What is the problem?

Possibly related, I started getting a

┌ Warning: Dependency graph not a DAG, linearizing anyway
└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Pkg\src\Operations.jl:985

warning, but that warning stays even after removing the using statement from startup.jl.

Looks like https://github.com/JuliaLang/Pkg.jl/commit/40d7f27f2ff08ec466df536f267129a9f5e950b4#diff-920ed338dcbd9d62489c6d12dc2fbb18 got lost. You should be able to work around it by starting julia with julia --startup-file=no for now.

1 Like

I am not sure what the problem is but I have found the following two possible workarounds.

A) Just comment out the “using OhMyREPL” in the start-up file, till this issue is sorted out:

# using OhMyREPL

B) Try the following code, which lets the OhMyREPL package to run in REPL but bypasses it when using Pkg package. (h/t @iht at iht (Israel Herraiz) · GitHub for this code at Loading OhMyREPL for interactive sessions only · Issue #68 · KristofferC/OhMyREPL.jl · GitHub)

try
    @eval using OhMyREPL
catch err
    @warn "Could not load OhMyREPL."
end
1 Like

@long-short , I tried your suggestion B) with Julia v1.0 on MacBook Pro, but it still failed with the following error:

(v1.0) pkg> build MbedTLS
  Building MbedTLS → `~/.julia/packages/MbedTLS/McYwM/deps/build.log`
┌ Error: Error building `MbedTLS`: 
│ ┌ Warning: Could not load OhMyREPL.
│ └ @ Main ~/.julia/config/startup.jl:10
│ ERROR: LoadError: ArgumentError: Package Statistics not found in current path:
│ - Run `Pkg.add("Statistics")` to install the Statistics package.
│ 
│ Stacktrace:
│  [1] require(::Module, ::Symbol) at ./loading.jl:817
│ in expression starting at /Users/xxx/.julia/config/startup.jl:14
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1068

What is in your startup.jl?

@kristoffer.carlsson, I’m sorry for the last posting. I just realized that the reason I got that error was that in my startup.jl, there’s another line using Statistics . I tried the same, i.e., suggestion B), then it worked! However, I’m very curious, I have another line using LinearAlgebra . For this package, I don’t need to do the same trick as OhMyREPL and Statistics. Why? Just in case, that part of my current startup.jl is:

try
    @eval using OhMyREPL
catch err
    @warn "Could not load OhMyREPL."
end

@eval using LinearAlgebra

try
    @eval using Statistics
catch err
    @warn "Could not load Statistics."
end

Probably because the package you build happen to have LinearAlgebra as one of the dependencies.