Can't get a .jl file to read a .jdl2 file in the same route folder

When running a file I get the following error:

ERROR: LoadError: ArgumentError: No file exists at given path: Datasets.jld2

I have tried loading the file from its own route first but doesn’t seem to help. The datasets file is in the same folder as the main .jl file and I’m not sure how to get it to read it.

I’m sure I’m missing something obvious but can’t for the life of me figure out what or see an existing thread with the same problem.

Thanks

Julia’s working directory may be different from the file it’s executing. One easy solution here is to use the special @__DIR__ macro to ensure the path is resolved relative to the Julia file:

JLD2.open(joinpath(@__DIR__, "Datasets.jld2"))

Does this need to be included in the main .jl file or can it be run prior to executing the main project?

I’ve resolved it via the cd(“path/to/dataset”) function. Didn’t know that julia’s base directory is that of the machine