Hey folks, I was having a little trouble getting some julia file system functions to work. The code seems correct, so I can’t tell if I made a code error, or if it is an issue with the vscode plugin, etc?
I have a julia .jl
file, and I set the working directory to the directory of the current file. Then I changed the working directory to a different directory that contains some “include” files. For some reason the include statement is still referring to the original working directory instead of the changed working directory.
Here is some sample code. Note that the relative directory work works and is good–no problems with the relative path.
cd(@__DIR__)
using Zygote
using Plots
gr()
cd(joinpath(@__DIR__, "../..", "opt_problems/"))
include("unconstrained_problems.jl")
include("regression_problems.jl")
The error I get is ERROR: SystemError: opening file "/.../julia/julia_opt/algfo_polished/3_bracketing/unconstrained_problems.jl": No such file or directory
. `
So the error is referencing the original working directory instead of the opt_problems
directory.
Is there some restriction on changing directories in a file, or am I only allowed to change the directory once?