Julia present working directory

Hello all,

I am bit confused in working directory of Julia. So if suppose i am working in “test” folder then the working directory of Julia should be “test” i-e if i write pwd() in Julia then it should give me the test folder? Also both “Project.toml” and “Manifest.toml” should be in the same (test) folder?

Thanks,

It would be useful if you can say why you think you are ‘working in’ the folder? To work in a particular folder, I would do one of two things:

  1. Start Julia from that folder (if you are in Windows, the / need to be \):
> cd /path/to/my/folder
> julia
  1. Run Julia, then set the folder (in this case, you can use / in Windows, too):
> julia
julia> cd("/path/to/my/folder")

Two questions: What did you do to set the ‘working’ folder?What do you get when you enter pwd()?

Is test a subfolder of a project? If it is, there should be Project.toml and Manifest.toml in the folder above. There can be Project.toml and Manifest.toml in the test folder, but there often isn’t.

Thank you so much for the detailed response. Actually I am working in a main folder called “Project” then there are sub folders of this namely “src” and “test”. In the main project folder i have Project.toml and Manifest.toml files, in the test folder i have these files too. Now what should i consider my working directory/environment when I am working on a file in “test” folder? should it be the main “Project” folder or the subfolder “test”. Also when i am working in a “test” folder and trying to call a module in “src” folder it give me an error and it says that module is not in the current path? For example see the following code

using Test

using question1

using Random

include(“test_lmcp.jl”)

Now i am running a code in a ‘test’ folder and my working environment in Julia is main “Project” folder and “question1” is a module in ‘src’ folder, when i try to run this code it gives me this error

ArgumentError: Package question1 not found in current path.
- Run import Pkg; Pkg.add("question1") to install the question1 package.

Now I dont know whats wrong here? which path should i be working in, it is bit confusing to me.

I suggest NOT to use the test folder as active folder. Always navigate to the project folder and start julia with

julia --project

To activate the test environment use the package GitHub - JuliaTesting/TestEnv.jl: Activate your test enviroment, so you can use your test dependencies in the REPL

I agree with @ufechner7 , it’s best to work in the top-level folder, and to work in a local environment using --project. If the top level is not package question1, you might need to do what the error message tells you, and add the package to that environment.

I have never used TestEnv.jl, but it looks like it could help you.