nautobot-docker-compose icon indicating copy to clipboard operation
nautobot-docker-compose copied to clipboard

Adding dependency "nautobot[napalm]" breaks Invoke's image URL generation

Open rlad78 opened this issue 2 months ago • 0 comments

I was trying to enable Napalm functionality on our Nautobot instance, using the instructions from Nautobot Documentation -> User Guide -> Administration -> Installation -> Installing Nautobot. In the context of the new poetry + Invoke setup, that just means doing the following:

poetry add nautobot[napalm]@2.1.1

That results in the following being changed in pyproject.toml:

- nautobot = "2.1.1"
+ nautobot = {version = "2.1.1", extras = ["napalm"]}

When running any Invoke command, the following lines get run: https://github.com/nautobot/nautobot-docker-compose/blob/40eec0879a0e8f271eedcaf0f67ade55166ca6b5/tasks.py#L44-L47

Which evaluates like so:

>>> parsed_toml["tool"]["poetry"]["dependencies"]["nautobot"]
{'version': '2.1.1', 'extras': ['napalm']}

...when, instead, the logic is intended to parse just the version string for the Nautobot dependency.

Later, when trying to synthesize the URL for the required Docker image, the following exception happens:

...

  File "/srv/docker-compose/nautobot-docker-compose-v2.0.0/tasks.py", line 90, in docker_compose
    return context.run(compose_command, env=compose_env, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/nautobot-docker-compose-ENx6_Wnd-py3.11/lib/python3.11/site-packages/invoke/context.py", line 104, in run
    return self._run(runner, command, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/nautobot-docker-compose-ENx6_Wnd-py3.11/lib/python3.11/site-packages/invoke/context.py", line 113, in _run
    return runner.run(command, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/nautobot-docker-compose-ENx6_Wnd-py3.11/lib/python3.11/site-packages/invoke/runners.py", line 395, in run
    return self._run_body(command, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/nautobot-docker-compose-ENx6_Wnd-py3.11/lib/python3.11/site-packages/invoke/runners.py", line 440, in _run_body
    self.start(command, self.opts["shell"], self.env)
  File "/root/.cache/pypoetry/virtualenvs/nautobot-docker-compose-ENx6_Wnd-py3.11/lib/python3.11/site-packages/invoke/runners.py", line 1337, in start
    self.process = Popen(
                   ^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.11/subprocess.py", line 1870, in _execute_child
    env_list.append(k + b'=' + os.fsencode(v))
                               ^^^^^^^^^^^^^^
  File "<frozen os>", line 812, in fsencode
TypeError: expected str, bytes or os.PathLike object, not DynamicInlineTableDict

rlad78 avatar May 01 '24 18:05 rlad78