We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[bug] Dynaconf doesn't load configuration file if cwd doesn't exist
**Describe the bug**
When the current workdir directory has been removed, dynaconf refuses to load configuration files.

**To Reproduce**
Steps to reproduce the behavior:

1. Having the following folder structure

<!-- Describe or use the command `$ tree -v` and paste below -->

<details>
<summary> Project structure </summary>

```bash

# /tmp/dyn.yaml
# /home/user/bug_dynaconf/
#             app.py
#             script.sh
```
</details>


2. Having the following config files:

<!-- Please adjust if you are using different files and formats! -->

<details>
<summary> Config files </summary>

**/tmp/dyn.yaml**
```yaml
offset: 24
```
</details>

3. Having the following app code:

<details>
<summary> Code </summary>

**app.py**
```python

from dynaconf import Dynaconf

settings = Dynaconf(
        settings_files=["/tmp/dyn.yaml"]
)

print(settings.offset)

settings.validators.validate()

print(type(settings.offset))

```

</details>

4. Executing under the following environment

<details>
<summary> Execution </summary>

**script.sh**
```bash
#!/bin/bash -x

python3 -m venv venv
source venv/bin/activate
pip install dynaconf==3.1.12
PARENT=$(realpath .)
mkdir nonexistent_dir
cd nonexistent_dir
rm -r ../nonexistent_dir
python $PARENT/app.py
```

</details>

**Expected behavior**
the `app.py` should have printed the type of `offset`, which is an `int`

**Actual behavior**
~~~Python
Traceback (most recent call last):
  File "/home/mtarral/debug_dynaconf/app.py", line 7, in <module>
    print(settings.offset)
  File "/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py", line 138, in __getattr__
    value = getattr(self._wrapped, name)
  File "/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py", line 300, in __getattribute__
    return super().__getattribute__(name)
AttributeError: 'Settings' object has no attribute 'OFFSET'
~~~

**Environment (please complete the following information):**
 - OS: ubuntu 20.04
 - Dynaconf Version 3.1.12

**Additional context**
Following https://github.com/dynaconf/dynaconf/issues/853, I tried to repro with 3.1.12, and found this issue now.

Thanks for dynaconf !

[bug] Dynaconf doesn't load configuration file if cwd doesn't exist
**Describe the bug**
When the current workdir directory has been removed, dynaconf refuses to load configuration files.

**To Reproduce**
Steps to reproduce the behavior:

1. Having the following folder structure

<!-- Describe or use the command `$ tree -v` and paste below -->

<details>
<summary> Project structure </summary>

```bash

# /tmp/dyn.yaml
# /home/user/bug_dynaconf/
#             app.py
#             script.sh
```
</details>


2. Having the following config files:

<!-- Please adjust if you are using different files and formats! -->

<details>
<summary> Config files </summary>

**/tmp/dyn.yaml**
```yaml
offset: 24
```
</details>

3. Having the following app code:

<details>
<summary> Code </summary>

**app.py**
```python

from dynaconf import Dynaconf

settings = Dynaconf(
        settings_files=["/tmp/dyn.yaml"]
)

print(settings.offset)

settings.validators.validate()

print(type(settings.offset))

```

</details>

4. Executing under the following environment

<details>
<summary> Execution </summary>

**script.sh**
```bash
#!/bin/bash -x

python3 -m venv venv
source venv/bin/activate
pip install dynaconf==3.1.12
PARENT=$(realpath .)
mkdir nonexistent_dir
cd nonexistent_dir
rm -r ../nonexistent_dir
python $PARENT/app.py
```

</details>

**Expected behavior**
the `app.py` should have printed the type of `offset`, which is an `int`

**Actual behavior**
~~~Python
Traceback (most recent call last):
  File "/home/mtarral/debug_dynaconf/app.py", line 7, in <module>
    print(settings.offset)
  File "/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py", line 138, in __getattr__
    value = getattr(self._wrapped, name)
  File "/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py", line 300, in __getattribute__
    return super().__getattribute__(name)
AttributeError: 'Settings' object has no attribute 'OFFSET'
~~~

**Environment (please complete the following information):**
 - OS: ubuntu 20.04
 - Dynaconf Version 3.1.12

**Additional context**
Following https://github.com/dynaconf/dynaconf/issues/853, I tried to repro with 3.1.12, and found this issue now.

Thanks for dynaconf !


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dynaconf/utils/files.py`
Content:
```
1 from __future__ import annotations
2 
3 import inspect
4 import io
5 import os
6 
7 from dynaconf.utils import deduplicate
8 
9 
10 def _walk_to_root(path, break_at=None):
11     """
12     Directories starting from the given directory up to the root or break_at
13     """
14     if not os.path.exists(path):  # pragma: no cover
15         raise OSError("Starting path not found")
16 
17     if os.path.isfile(path):  # pragma: no cover
18         path = os.path.dirname(path)
19 
20     last_dir = None
21     current_dir = os.path.abspath(path)
22     paths = []
23     while last_dir != current_dir:
24         paths.append(current_dir)
25         paths.append(os.path.join(current_dir, "config"))
26         if break_at and current_dir == os.path.abspath(break_at):  # noqa
27             break
28         parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir))
29         last_dir, current_dir = current_dir, parent_dir
30     return paths
31 
32 
33 SEARCHTREE = []
34 
35 
36 def find_file(filename=".env", project_root=None, skip_files=None, **kwargs):
37     """Search in increasingly higher folders for the given file
38     Returns path to the file if found, or an empty string otherwise.
39 
40     This function will build a `search_tree` based on:
41 
42     - Project_root if specified
43     - Invoked script location and its parents until root
44     - Current working directory
45 
46     For each path in the `search_tree` it will also look for an
47     additional `./config` folder.
48     """
49     search_tree = []
50     try:
51         work_dir = os.getcwd()
52     except FileNotFoundError:
53         return ""
54     skip_files = skip_files or []
55 
56     # If filename is an absolute path and exists, just return it
57     # if the absolute path does not exist, return empty string so
58     # that it can be joined and avoid IoError
59     if os.path.isabs(filename):
60         return filename if os.path.exists(filename) else ""
61 
62     if project_root is not None:
63         search_tree.extend(_walk_to_root(project_root, break_at=work_dir))
64 
65     script_dir = os.path.dirname(os.path.abspath(inspect.stack()[-1].filename))
66 
67     # Path to invoked script and recursively to root with its ./config dirs
68     search_tree.extend(_walk_to_root(script_dir))
69 
70     # Path to where Python interpreter was invoked and recursively to root
71     search_tree.extend(_walk_to_root(work_dir))
72 
73     # Don't look the same place twice
74     search_tree = deduplicate(search_tree)
75 
76     global SEARCHTREE
77     SEARCHTREE[:] = search_tree
78 
79     for dirname in search_tree:
80         check_path = os.path.join(dirname, filename)
81         if check_path in skip_files:
82             continue
83         if os.path.exists(check_path):
84             return check_path  # First found will return
85 
86     # return empty string if not found so it can still be joined in os.path
87     return ""
88 
89 
90 def read_file(path, **kwargs):
91     content = ""
92     with open(path, **kwargs) as open_file:
93         content = open_file.read().strip()
94     return content
95 
96 
97 def get_local_filename(filename):
98     """Takes a filename like `settings.toml` and returns `settings.local.toml`
99 
100     Arguments:
101         filename {str} -- The filename or complete path
102 
103     Returns:
104         [str] -- The same name or path with `.local.` added.
105     """
106     name, _, extension = os.path.basename(str(filename)).rpartition(
107         os.path.extsep
108     )
109 
110     return os.path.join(
111         os.path.dirname(str(filename)), f"{name}.local.{extension}"
112     )
113
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dynaconf/utils/files.py b/dynaconf/utils/files.py
--- a/dynaconf/utils/files.py
+++ b/dynaconf/utils/files.py
@@ -46,6 +46,12 @@
     For each path in the `search_tree` it will also look for an
     additional `./config` folder.
     """
+    # If filename is an absolute path and exists, just return it
+    # if the absolute path does not exist, return empty string so
+    # that it can be joined and avoid IoError
+    if os.path.isabs(filename):
+        return filename if os.path.exists(filename) else ""
+
     search_tree = []
     try:
         work_dir = os.getcwd()
@@ -53,12 +59,6 @@
         return ""
     skip_files = skip_files or []
 
-    # If filename is an absolute path and exists, just return it
-    # if the absolute path does not exist, return empty string so
-    # that it can be joined and avoid IoError
-    if os.path.isabs(filename):
-        return filename if os.path.exists(filename) else ""
-
     if project_root is not None:
         search_tree.extend(_walk_to_root(project_root, break_at=work_dir))

{"golden_diff": "diff --git a/dynaconf/utils/files.py b/dynaconf/utils/files.py\n--- a/dynaconf/utils/files.py\n+++ b/dynaconf/utils/files.py\n@@ -46,6 +46,12 @@\n     For each path in the `search_tree` it will also look for an\n     additional `./config` folder.\n     \"\"\"\n+    # If filename is an absolute path and exists, just return it\n+    # if the absolute path does not exist, return empty string so\n+    # that it can be joined and avoid IoError\n+    if os.path.isabs(filename):\n+        return filename if os.path.exists(filename) else \"\"\n+\n     search_tree = []\n     try:\n         work_dir = os.getcwd()\n@@ -53,12 +59,6 @@\n         return \"\"\n     skip_files = skip_files or []\n \n-    # If filename is an absolute path and exists, just return it\n-    # if the absolute path does not exist, return empty string so\n-    # that it can be joined and avoid IoError\n-    if os.path.isabs(filename):\n-        return filename if os.path.exists(filename) else \"\"\n-\n     if project_root is not None:\n         search_tree.extend(_walk_to_root(project_root, break_at=work_dir))\n", "issue": "[bug] Dynaconf doesn't load configuration file if cwd doesn't exist\n**Describe the bug**\r\nWhen the current workdir directory has been removed, dynaconf refuses to load configuration files.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n\r\n1. Having the following folder structure\r\n\r\n<!-- Describe or use the command `$ tree -v` and paste below -->\r\n\r\n<details>\r\n<summary> Project structure </summary>\r\n\r\n```bash\r\n\r\n# /tmp/dyn.yaml\r\n# /home/user/bug_dynaconf/\r\n#             app.py\r\n#             script.sh\r\n```\r\n</details>\r\n\r\n\r\n2. Having the following config files:\r\n\r\n<!-- Please adjust if you are using different files and formats! -->\r\n\r\n<details>\r\n<summary> Config files </summary>\r\n\r\n**/tmp/dyn.yaml**\r\n```yaml\r\noffset: 24\r\n```\r\n</details>\r\n\r\n3. Having the following app code:\r\n\r\n<details>\r\n<summary> Code </summary>\r\n\r\n**app.py**\r\n```python\r\n\r\nfrom dynaconf import Dynaconf\r\n\r\nsettings = Dynaconf(\r\n        settings_files=[\"/tmp/dyn.yaml\"]\r\n)\r\n\r\nprint(settings.offset)\r\n\r\nsettings.validators.validate()\r\n\r\nprint(type(settings.offset))\r\n\r\n```\r\n\r\n</details>\r\n\r\n4. Executing under the following environment\r\n\r\n<details>\r\n<summary> Execution </summary>\r\n\r\n**script.sh**\r\n```bash\r\n#!/bin/bash -x\r\n\r\npython3 -m venv venv\r\nsource venv/bin/activate\r\npip install dynaconf==3.1.12\r\nPARENT=$(realpath .)\r\nmkdir nonexistent_dir\r\ncd nonexistent_dir\r\nrm -r ../nonexistent_dir\r\npython $PARENT/app.py\r\n```\r\n\r\n</details>\r\n\r\n**Expected behavior**\r\nthe `app.py` should have printed the type of `offset`, which is an `int`\r\n\r\n**Actual behavior**\r\n~~~Python\r\nTraceback (most recent call last):\r\n  File \"/home/mtarral/debug_dynaconf/app.py\", line 7, in <module>\r\n    print(settings.offset)\r\n  File \"/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py\", line 138, in __getattr__\r\n    value = getattr(self._wrapped, name)\r\n  File \"/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py\", line 300, in __getattribute__\r\n    return super().__getattribute__(name)\r\nAttributeError: 'Settings' object has no attribute 'OFFSET'\r\n~~~\r\n\r\n**Environment (please complete the following information):**\r\n - OS: ubuntu 20.04\r\n - Dynaconf Version 3.1.12\r\n\r\n**Additional context**\r\nFollowing https://github.com/dynaconf/dynaconf/issues/853, I tried to repro with 3.1.12, and found this issue now.\r\n\r\nThanks for dynaconf !\r\n\n[bug] Dynaconf doesn't load configuration file if cwd doesn't exist\n**Describe the bug**\r\nWhen the current workdir directory has been removed, dynaconf refuses to load configuration files.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n\r\n1. Having the following folder structure\r\n\r\n<!-- Describe or use the command `$ tree -v` and paste below -->\r\n\r\n<details>\r\n<summary> Project structure </summary>\r\n\r\n```bash\r\n\r\n# /tmp/dyn.yaml\r\n# /home/user/bug_dynaconf/\r\n#             app.py\r\n#             script.sh\r\n```\r\n</details>\r\n\r\n\r\n2. Having the following config files:\r\n\r\n<!-- Please adjust if you are using different files and formats! -->\r\n\r\n<details>\r\n<summary> Config files </summary>\r\n\r\n**/tmp/dyn.yaml**\r\n```yaml\r\noffset: 24\r\n```\r\n</details>\r\n\r\n3. Having the following app code:\r\n\r\n<details>\r\n<summary> Code </summary>\r\n\r\n**app.py**\r\n```python\r\n\r\nfrom dynaconf import Dynaconf\r\n\r\nsettings = Dynaconf(\r\n        settings_files=[\"/tmp/dyn.yaml\"]\r\n)\r\n\r\nprint(settings.offset)\r\n\r\nsettings.validators.validate()\r\n\r\nprint(type(settings.offset))\r\n\r\n```\r\n\r\n</details>\r\n\r\n4. Executing under the following environment\r\n\r\n<details>\r\n<summary> Execution </summary>\r\n\r\n**script.sh**\r\n```bash\r\n#!/bin/bash -x\r\n\r\npython3 -m venv venv\r\nsource venv/bin/activate\r\npip install dynaconf==3.1.12\r\nPARENT=$(realpath .)\r\nmkdir nonexistent_dir\r\ncd nonexistent_dir\r\nrm -r ../nonexistent_dir\r\npython $PARENT/app.py\r\n```\r\n\r\n</details>\r\n\r\n**Expected behavior**\r\nthe `app.py` should have printed the type of `offset`, which is an `int`\r\n\r\n**Actual behavior**\r\n~~~Python\r\nTraceback (most recent call last):\r\n  File \"/home/mtarral/debug_dynaconf/app.py\", line 7, in <module>\r\n    print(settings.offset)\r\n  File \"/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py\", line 138, in __getattr__\r\n    value = getattr(self._wrapped, name)\r\n  File \"/home/mtarral/debug_dynaconf/venv/lib/python3.8/site-packages/dynaconf/base.py\", line 300, in __getattribute__\r\n    return super().__getattribute__(name)\r\nAttributeError: 'Settings' object has no attribute 'OFFSET'\r\n~~~\r\n\r\n**Environment (please complete the following information):**\r\n - OS: ubuntu 20.04\r\n - Dynaconf Version 3.1.12\r\n\r\n**Additional context**\r\nFollowing https://github.com/dynaconf/dynaconf/issues/853, I tried to repro with 3.1.12, and found this issue now.\r\n\r\nThanks for dynaconf !\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport inspect\nimport io\nimport os\n\nfrom dynaconf.utils import deduplicate\n\n\ndef _walk_to_root(path, break_at=None):\n    \"\"\"\n    Directories starting from the given directory up to the root or break_at\n    \"\"\"\n    if not os.path.exists(path):  # pragma: no cover\n        raise OSError(\"Starting path not found\")\n\n    if os.path.isfile(path):  # pragma: no cover\n        path = os.path.dirname(path)\n\n    last_dir = None\n    current_dir = os.path.abspath(path)\n    paths = []\n    while last_dir != current_dir:\n        paths.append(current_dir)\n        paths.append(os.path.join(current_dir, \"config\"))\n        if break_at and current_dir == os.path.abspath(break_at):  # noqa\n            break\n        parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir))\n        last_dir, current_dir = current_dir, parent_dir\n    return paths\n\n\nSEARCHTREE = []\n\n\ndef find_file(filename=\".env\", project_root=None, skip_files=None, **kwargs):\n    \"\"\"Search in increasingly higher folders for the given file\n    Returns path to the file if found, or an empty string otherwise.\n\n    This function will build a `search_tree` based on:\n\n    - Project_root if specified\n    - Invoked script location and its parents until root\n    - Current working directory\n\n    For each path in the `search_tree` it will also look for an\n    additional `./config` folder.\n    \"\"\"\n    search_tree = []\n    try:\n        work_dir = os.getcwd()\n    except FileNotFoundError:\n        return \"\"\n    skip_files = skip_files or []\n\n    # If filename is an absolute path and exists, just return it\n    # if the absolute path does not exist, return empty string so\n    # that it can be joined and avoid IoError\n    if os.path.isabs(filename):\n        return filename if os.path.exists(filename) else \"\"\n\n    if project_root is not None:\n        search_tree.extend(_walk_to_root(project_root, break_at=work_dir))\n\n    script_dir = os.path.dirname(os.path.abspath(inspect.stack()[-1].filename))\n\n    # Path to invoked script and recursively to root with its ./config dirs\n    search_tree.extend(_walk_to_root(script_dir))\n\n    # Path to where Python interpreter was invoked and recursively to root\n    search_tree.extend(_walk_to_root(work_dir))\n\n    # Don't look the same place twice\n    search_tree = deduplicate(search_tree)\n\n    global SEARCHTREE\n    SEARCHTREE[:] = search_tree\n\n    for dirname in search_tree:\n        check_path = os.path.join(dirname, filename)\n        if check_path in skip_files:\n            continue\n        if os.path.exists(check_path):\n            return check_path  # First found will return\n\n    # return empty string if not found so it can still be joined in os.path\n    return \"\"\n\n\ndef read_file(path, **kwargs):\n    content = \"\"\n    with open(path, **kwargs) as open_file:\n        content = open_file.read().strip()\n    return content\n\n\ndef get_local_filename(filename):\n    \"\"\"Takes a filename like `settings.toml` and returns `settings.local.toml`\n\n    Arguments:\n        filename {str} -- The filename or complete path\n\n    Returns:\n        [str] -- The same name or path with `.local.` added.\n    \"\"\"\n    name, _, extension = os.path.basename(str(filename)).rpartition(\n        os.path.extsep\n    )\n\n    return os.path.join(\n        os.path.dirname(str(filename)), f\"{name}.local.{extension}\"\n    )\n", "path": "dynaconf/utils/files.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport inspect\nimport io\nimport os\n\nfrom dynaconf.utils import deduplicate\n\n\ndef _walk_to_root(path, break_at=None):\n    \"\"\"\n    Directories starting from the given directory up to the root or break_at\n    \"\"\"\n    if not os.path.exists(path):  # pragma: no cover\n        raise OSError(\"Starting path not found\")\n\n    if os.path.isfile(path):  # pragma: no cover\n        path = os.path.dirname(path)\n\n    last_dir = None\n    current_dir = os.path.abspath(path)\n    paths = []\n    while last_dir != current_dir:\n        paths.append(current_dir)\n        paths.append(os.path.join(current_dir, \"config\"))\n        if break_at and current_dir == os.path.abspath(break_at):  # noqa\n            break\n        parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir))\n        last_dir, current_dir = current_dir, parent_dir\n    return paths\n\n\nSEARCHTREE = []\n\n\ndef find_file(filename=\".env\", project_root=None, skip_files=None, **kwargs):\n    \"\"\"Search in increasingly higher folders for the given file\n    Returns path to the file if found, or an empty string otherwise.\n\n    This function will build a `search_tree` based on:\n\n    - Project_root if specified\n    - Invoked script location and its parents until root\n    - Current working directory\n\n    For each path in the `search_tree` it will also look for an\n    additional `./config` folder.\n    \"\"\"\n    # If filename is an absolute path and exists, just return it\n    # if the absolute path does not exist, return empty string so\n    # that it can be joined and avoid IoError\n    if os.path.isabs(filename):\n        return filename if os.path.exists(filename) else \"\"\n\n    search_tree = []\n    try:\n        work_dir = os.getcwd()\n    except FileNotFoundError:\n        return \"\"\n    skip_files = skip_files or []\n\n    if project_root is not None:\n        search_tree.extend(_walk_to_root(project_root, break_at=work_dir))\n\n    script_dir = os.path.dirname(os.path.abspath(inspect.stack()[-1].filename))\n\n    # Path to invoked script and recursively to root with its ./config dirs\n    search_tree.extend(_walk_to_root(script_dir))\n\n    # Path to where Python interpreter was invoked and recursively to root\n    search_tree.extend(_walk_to_root(work_dir))\n\n    # Don't look the same place twice\n    search_tree = deduplicate(search_tree)\n\n    global SEARCHTREE\n    SEARCHTREE[:] = search_tree\n\n    for dirname in search_tree:\n        check_path = os.path.join(dirname, filename)\n        if check_path in skip_files:\n            continue\n        if os.path.exists(check_path):\n            return check_path  # First found will return\n\n    # return empty string if not found so it can still be joined in os.path\n    return \"\"\n\n\ndef read_file(path, **kwargs):\n    content = \"\"\n    with open(path, **kwargs) as open_file:\n        content = open_file.read().strip()\n    return content\n\n\ndef get_local_filename(filename):\n    \"\"\"Takes a filename like `settings.toml` and returns `settings.local.toml`\n\n    Arguments:\n        filename {str} -- The filename or complete path\n\n    Returns:\n        [str] -- The same name or path with `.local.` added.\n    \"\"\"\n    name, _, extension = os.path.basename(str(filename)).rpartition(\n        os.path.extsep\n    )\n\n    return os.path.join(\n        os.path.dirname(str(filename)), f\"{name}.local.{extension}\"\n    )\n", "path": "dynaconf/utils/files.py"}]}