txt: ## -chdir.md
  &\*chdir
  
  Combined from primary sources listed below.
  
  # [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_sub_&amp;*chdir "direct link")
  
  See primary documentation
  [in context](/type/independent-routines#sub_&*chdir)
  for **sub &\*chdir**.
  
  ```raku
  PROCESS::<&chdir> = sub (IO() $path --> IO::Path:D) { }
  
  ```
  
  Changes value of `$*CWD` variable to the provided `$path` and sets the process's current directory to the value of [`$path.absolute`](/routine/absolute). **NOTE:** that in most cases, you want to use [`chdir`](/routine/chdir) routine instead.
  
  Returns an [`IO::Path`](/type/IO/Path) representing the new `$*CWD` on success. On failure, returns [`Failure`](/type/Failure) and leaves `$*CWD` untouched. The `$path` can be any object with an IO method that returns an [`IO::Path`](/type/IO/Path) object.
  
  Note that unlike regular [`chdir`](/routine/chdir), there are no arguments to specify which file tests to perform.
  
  ```raku
  &*chdir('/tmp');  # change $*CWD and process's current directory to '/tmp'
  &*chdir('/not-there'); # returns Failure
  
  ```
  
  Note that the following construct is a mistake:
  
  ```raku
  # WRONG! DO NOT DO THIS!
  my $*CWD = &*chdir('/tmp');
  
  ```
  
  Use the following, instead; or see [`indir`](/routine/indir) if you do not need to change process's current directory:
  
  ```raku
  temp $*CWD;
  &*chdir('/tmp');
  
  ```
  