Generation of Octoprint plugin skeleton fails

What is the problem?

Generation of Octoprint plugin skeleton fails when using the "octoprint dev plugin:new" or " cookiecutter gh:OctoPrint/cookiecutter-octoprint-plugin" command with the following trace:

 octoprint dev plugin:new                               
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Scripts\octoprint.exe\", line 7, in <module>
  File "C:\Users\Till\PycharmProjects\2FAPluginOctoprint\OctoPrint\src\octoprint\", line 1008, in main
    octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\", line 1078, in main
    rv = self.invoke(ctx)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Till\PycharmProjects\2FAPluginOctoprint\OctoPrint\src\octoprint\cli\", line 37, in invoke
    return self._impl.invoke(ctx)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\", line 1682, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\", line 1729, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "C:\Users\Till\PycharmProjects\2FAPluginOctoprint\OctoPrint\src\octoprint\cli\", line 65, in get_command
    commands = self._get_commands()
  File "C:\Users\Till\PycharmProjects\2FAPluginOctoprint\OctoPrint\src\octoprint\cli\", line 55, in _get_commands
    for command in self._get_commands_from_prefix_methods(f"{group}_"):
  File "C:\Users\Till\PycharmProjects\2FAPluginOctoprint\OctoPrint\src\octoprint\cli\", line 48, in _get_commands_from_prefix_methods
    result = method()
  File "C:\Users\Till\PycharmProjects\2FAPluginOctoprint\OctoPrint\src\octoprint\cli\", line 70, in plugin_new
    import cookiecutter.main
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\cookiecutter\", line 22, in <module>
    from .repository import determine_repo_dir
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\site-packages\cookiecutter\", line 11, in <module>
    REPO_REGEX = re.compile(r"""
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\re\", line 227, in compile
    return _compile(pattern, flags)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\re\", line 294, in _compile
    p = _compiler.compile(pattern, flags)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\re\", line 743, in compile
    p = _parser.parse(p, flags)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\re\", line 980, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\re\", line 455, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "C:\Users\Till\AppData\Local\Programs\Python\Python311\Lib\re\", line 841, in _parse
    raise source.error('global flags not at the start '
re.error: global flags not at the start of the expression at position 1 (line 2, column 1)

What did you already try to solve it?

Google the problem, tried to install different cookiecutter versions
reinstalling the environment and the plugin an development dependencies

Have you tried running in safe mode?

Octoprint not running

Did running in safe mode solve the problem?


Additional information about your setup

New Octoprint installation
virtualenv used

I'm not quite sure on the source of this error at a brief look, but

Your stack trace indicated OctoPrint & co are installed system-wide, and that's where it's running from. It's not running from a virtual environment.

I'm not sure how much of a difference it would make, but I am not sure if you might have installed something in the wrong place if you thought it was installed with virtualenv.

Yeah, thanks, I just glanced over the stacktrace, but the issue doesn't lie in the installation location of octoprint rather than the dependency itself.

I fixed it myself. The regex, that checks if the url to the repository is valid seems to be off, so I made it always return true. Now it works :person_shrugging:.

Thanks for your help.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.