Why do I get this error when ever I add a new package?

ok so whenever I add a new package to a project no matter what it is when I try to run it I get this ERROR: LoadError: ArgumentError: Package X not found in current path. even though I did ] add X right now I am using sdl and idk what to do to fix this

What is your operating system? How did you install Julia? What is the output of:

versioninfo()

I am on windows 11, I used the installer and I get this Julia Version 1.9.4 Commit 8e5136fa29 (2023-11-14 08:46 UTC) Build Info: Official https://julialang.org/ release Platform Info: OS: Windows (x86_64-w64-mingw32) CPU: 8 Ă— AMD Ryzen 3 5300G with Radeon Graphics WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-14.0.6 (ORCJIT, znver3) Threads: 1 on 8 virtual cores Environment: JULIA_EDITOR = code JULIA_NUM_THREADS =

Which package are you trying to install?

What happens if you type in a terminal window:

mkdir test
cd test
julia --project="."

and then, on the Julia prompt type:

using Pkg
Pkg.add("DataFrames")

Just as example.

Extra question:
Does your home directory, which usually has the name of your username contain any space or special character?

And if you post any code or output, please enclose it in triple backticks, like this: ```

I am trying to install SDL

More interestingly, how are you executing your code, and what is the output of ] st?

so my file is called SDLJulia.jl and I do julia SDLJulia.jl and the status is this Project SDLJulia v0.1.0 Status `C:\Users\swirl\OneDrive\Desktop\Julia\SDLJulia\Project.toml` [98e33af6] SimpleDirectMediaLayer v0.4.0

Well, if you work with local projects you need to launch julia with

julia --project

So what is the output if you launch Julia with the parameter --project in the folder C:\Users\swirl\OneDrive\Desktop\Julia\SDLJulia\ and then type:

using SimpleDirectMediaLayer

If that works, you installed this package successfully, if not please post the error message in triple backticks.

And if you want to execute the file “SDLJulia.jl” please include it from the command line like this:

include("SDLJulia.jl")

after launching Julia with the parameter --project.

Just tested this on Windows 10 and it works for me, so the package is not broken.

Explanation:
Many people install everything in the global environment (never launch Julia with the parameter --project), and then they might get into trouble if some old packages do not play well together with new packages…

Better to have a Project.toml file per project and install in each project (=folder) only the packages needed for that project…

1 Like