I am trying to enable private files via features, in code, or with drush but am getting errors.
drush vset file_private_path sites/default/files/private
The problem is that when you set this configuration manually, the file system settings form gets saved and it creates an .htaccess file in that location. When you set it in code, it doesn't create the .htaccess file until you visit the admin/config/media/file-system page, which it returns an error the first time:
Warning: file_put_contents(private:///.htaccess) [function.file-put-contents]: failed to open stream: "DrupalPrivateStreamWrapper::stream_open" call failed in file_create_htaccess() (line 502 of /sandbox/d7/includes/file.inc).
Is there a correct way to be doing this programmatically? Thanks in advance.