Set the current working directory.


  1. Change directory and execute a function:

    julia> function print_current_dir()
    julia> cd(print_current_dir, dir="/path/to/directory")

    This example changes the current working directory to /path/to/directory and executes the print_current_dir function, which prints the current working directory.

  2. Change directory using the default home directory:

    julia> cd(print_current_dir)

    In this case, the current working directory is changed to the home directory (homedir()) and the print_current_dir function is executed.

Common mistake example:

julia> cd(print_current_dir, "/path/to/invalid/directory")
ERROR: SystemError: chdir: no such file or directory (ENOENT)

In this example, the directory path provided (/path/to/invalid/directory) does not exist, resulting in a SystemError. Make sure to provide a valid directory path to the cd function to avoid such errors.

See Also

addprocs, atexit, cd, clipboard, EnvHash, exit, getpid, peakflops, ProcessExitedException, process_exited, process_running, procs, quit, readandwrite, redirect_stdout, rmprocs, run, setenv, spawn, withenv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: