How do I get the path for the private filesystem? I just trying to get the real path of my private filesystem but I just obtain an empty string if I use:

\Drupal::service('file_system')-&gt;realpath("private://");


There one user in Get the public path directory that says that this is the correct way, but this is not working for me.

My private filesystem is configured as:

$settings['file_private_path'] = '/User/adriancid/private-drupal-folder';




If I use file_default_scheme() I see:


  private
The problem is solved.

I had a problem with the path, so the correct path is

$settings['file_private_path'] = '/Users/adriancid/private-drupal-folder';


And I give permissions to write in the folder to the webserver.