Repository: nautobot/nautobot

Issue:
Install issue 2.0.1 -> collect static fails to create directories
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable): 2.0.1
* Python version: 3.10.12
* Database platform, version: postgres
* Middleware(s):none

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. New installation of nautobot
2. Following instructions at https://blog.networktocode.com/post/installing-nautobot/
3. Issue command nautobot-server collectstatic

<!-- What did you expect to happen? -->
### Expected Behavior
Expected directories to be created and static files to be collected

<!-- What happened instead? -->
Error occurred

nautobot@server:~$ nautobot-server collectstatic
16:21:56.992 ERROR   nautobot.core.apps :
  Error in link construction for Notes: Reverse for 'note_list' not found. 'note_list' is not a valid view function or pattern name.
Traceback (most recent call last):
  File "/opt/nautobot/bin/nautobot-server", line 8, in <module>
    sys.exit(main())
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/cli/__init__.py", line 54, in main
    run_app(
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot/core/runner/runner.py", line 297, in run_app
    management.execute_from_command_line([runner_name, command] + command_args)
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
    collected = self.collect()
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
    for path, storage in finder.list(self.ignore_patterns):
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/staticfiles/finders.py", line 130, in list
    for path in utils.get_files(storage, ignore_patterns):
  File "/opt/nautobot/lib/python3.10/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
    directories, files = storage.listdir(location)
  File "/opt/nautobot/lib/python3.10/site-packages/django/core/files/storage.py", line 330, in listdir
    for entry in os.scandir(path):
FileNotFoundError: [Errno 2] No such file or directory: '/opt/nautobot/ui/build/static'



As a workaround, I manually created /opt/nautobot/ui/build/static and re-ran collectstatic


Discussion:
Temporary workaround:

If you create that structure yourself (assuming you have the config dir mapped in your docker container) and restart nautobot it works

I use volume mapping`/opt/nautobot/config:/opt/nautobot` in my docker file and created the full path `/opt/nautobot/config/ui/build/static`

edit: not working all the way unfortunatally, the images and menu are not working
Confirmed that works, and was my work around as well.

On Sat, Nov 4, 2023 at 11:03 AM Bart Smeding ***@***.***>
wrote:

> Temporary workaround:
>
> If you create that structure yourself (assuming you have the config dir
> mapped in your docker container) and restart nautobot it works
>
> I use volume mapping/opt/nautobot/config:/opt/nautobot in my docker file
> and created the full path /opt/nautobot/config/ui/build/static
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/nautobot/nautobot/issues/4620#issuecomment-1793484006>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AZ4D7ZKM5RRVDJGLDDMDPVDYCZRLZAVCNFSM6AAAAAA5XA7RPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGQ4DIMBQGY>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>

O yeah see now in you're last line, sorry overlooked
No worries.  I just figured someone would update the script to create the
path

On Sat, Nov 4, 2023 at 11:06 AM Bart Smeding ***@***.***>
wrote:

> O yeah see now in you're last line, sorry overlooked
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/nautobot/nautobot/issues/4620#issuecomment-1793484650>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AZ4D7ZLAKMZEAUWB42KYUZLYCZRX7AVCNFSM6AAAAAA5XA7RPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGQ4DINRVGA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>

@lampwins is the fix here to:

- [x] Update the blog post with 2.x installation instructions?
- [ ] Update collectstatic to create any necessary directories? (This would have to be vendored from django)
Let's update the blog

Resolving patch:
diff --git a/nautobot/core/cli/__init__.py b/nautobot/core/cli/__init__.py
--- a/nautobot/core/cli/__init__.py
+++ b/nautobot/core/cli/__init__.py
@@ -115,6 +115,7 @@ def _configure_settings(config):
     os.makedirs(settings.MEDIA_ROOT, exist_ok=True)
     os.makedirs(os.path.join(settings.MEDIA_ROOT, "devicetype-images"), exist_ok=True)
     os.makedirs(os.path.join(settings.MEDIA_ROOT, "image-attachments"), exist_ok=True)
+    os.makedirs(os.path.join(settings.NAUTOBOT_UI_DIR, "build", "static"), exist_ok=True)
     os.makedirs(settings.STATIC_ROOT, exist_ok=True)
 
     #


Test patch: