This error may occur when running a container as a non-root user
You should be able to set either PREFECT_LOCAL_STORAGE_PATH
or PREFECT_HOME
as an environment variable to a path that this non-user has access to e.g. this may be set to the same directory as the WORKDIR in a Dockerfile
more on this approach:
opened 09:51AM - 22 Jul 22 UTC
closed 05:32PM - 12 Oct 22 UTC
from:slack
v2
## Opened from the [Prefect Public Slack Community](https://prefect.io/slack)
…
**andreas.nigg**: Hey. I just upgraded to prefect 2.0b11 and I've an agent running in a rather restrictive kubernetes environment - meaning I can't run it as root.
This results in having this warning at the Agent startup:
```
/usr/local/lib/python3.9/site-packages/prefect/context.py:461: UserWarning: Failed to create the Prefect home directory at /.prefect
with SettingsContext(profile=profile, settings=new_settings) as ctx:
```
While Agent still starts up and picks up flow-runs, I get the following exception during flow-run
```
File "/usr/local/lib/python3.9/pathlib.py", line 1323, in mkdir
self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/.prefect/storage'
```
I guess this has something to do with removing storage/default storage in the latest release? I configured my deployment with a RemoteFileSystem - Packager - not sure why prefect still needs to write something locally?
Find my flow + deployment in the Thread.
**andreas.nigg**:
```python
from prefect import flow, task
from prefect.deployments import Deployment
from prefect.filesystems import RemoteFileSystem
from prefect.logging import get_run_logger
from prefect.packaging import FilePackager
@task
def greet_world():
logger = get_run_logger()
logger.info("Hello world!")
@flow
def give_greeting() -> str:
greet_world()
minio_packager = FilePackager(filesystem=RemoteFileSystem(
basepath="gcs://rm-datateam-prefect-global-storage",
settings={
"type":
"service_account",
"project_id":
....
}))
Deployment(flow=give_greeting,
name="minio_file_package_with_remote_s3fs",
tags=["os4"],
packager=minio_packager)
if __name__ == "__main__":
give_greeting()
```
**andreas.nigg**: (By the way sorry for the bad variable names... I use an object called "minio_packager" for GCS :facepalm: )
**anna**: Thanks for reporting that, I assume this is the place where Prefect wants to store local results now but which didn't get created automatically
let me open an issue and ask the team why this folder
<@ULVA73B9P> open "2.0b11 throws `FileNotFoundError: [Errno 2] No such file or directory: '/.prefect/storage'` with Orion set up on Kubernetes"
Original thread can be found [here](https://prefect-community.slack.com/archives/CL09KU1K7/p1658482578521859?thread_ts=1658482578.521859&cid=CL09KU1K7).
Another possibility is to add an emptyDir
volume and an init container in which you change permissions of the volume (example here ). The manifest it applies to can be found here
1 Like