# Error with Pkg with using statement in startup.jl

**URL:** <https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127>\
**Category:** General Usage\
**Created:** [August 9, 2018, 11:20pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127 "2018-08-09T23:20:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [August 9, 2018, 11:20pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/1 "2018-08-09T23:20:16Z")

</div>

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

```julia
  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?

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [August 9, 2018, 11:21pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/2 "2018-08-09T23:21:42Z")

</div>

Possibly related, I started getting a

```julia
┌ 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`.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [August 10, 2018, 12:03am UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/3 "2018-08-10T00:03:16Z")

</div>

Looks like [https://github.com/JuliaLang/Pkg.jl/commit/40d7f27f2ff08ec466df536f267129a9f5e950b4#diff-920ed338dcbd9d62489c6d12dc2fbb18](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.

---

<div class="post-metadata">

**Author:** ![long-short](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@long-short](https://discourse.julialang.org/u/long-short)\
**Post date:** [September 5, 2018, 12:57pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/4 "2018-09-05T12:57:24Z")

</div>

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:

```julia
# 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](https://github.com/iht) for this code at [Loading OhMyREPL for interactive sessions only · Issue #68 · KristofferC/OhMyREPL.jl · GitHub](https://github.com/KristofferC/OhMyREPL.jl/issues/68#issuecomment-414714989))

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

```

---

<div class="post-metadata">

**Author:** ![BVPs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bvps/32/2190_2.png) [@BVPs](https://discourse.julialang.org/u/BVPs)\
**Post date:** [September 23, 2018, 7:03pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/5 "2018-09-23T19:03:49Z")

</div>

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

```julia
(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

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [September 23, 2018, 7:11pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/6 "2018-09-23T19:11:14Z")

</div>

What is in your `startup.jl`?

---

<div class="post-metadata">

**Author:** ![BVPs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bvps/32/2190_2.png) [@BVPs](https://discourse.julialang.org/u/BVPs)\
**Post date:** [September 23, 2018, 7:19pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/7 "2018-09-23T19:19:05Z")

</div>

@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:

```julia
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

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [September 23, 2018, 7:20pm UTC](https://discourse.julialang.org/t/error-with-pkg-with-using-statement-in-startup-jl/13127/8 "2018-09-23T19:20:12Z")

</div>

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