We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Missing dependency in requirements.txt (cookiecutter) 
https://github.com/ckan/ckan/blob/f2cea089bc0aaeede06d98449c4e9eb65e8c2f14/ckan/cli/generate.py#L7

- cookiecutter lib will be imported on a `ckan` cli attempt, but as it is missing from requirments.txt, is not present which will result to ImportError 

- cookiecutter is listed in requirments-dev.txt, but docker builds don't use it

Tested on a docker personal build, by : 
> docker build -t ckan .
> docker run --rm -it --entrypoint bash --name ckan -p 5000:5000 --link db:db --link redis:redis --link solr:solr ckan
> (activated-env)
> ckan

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ckan/cli/generate.py`
Content:
```
1 # encoding: utf-8
2 
3 import os
4 import sys
5 import click
6 from ckan.cli import error_shout
7 from cookiecutter.main import cookiecutter
8 
9 
10 @click.group(name=u'generate',
11              short_help=u"Generate empty extension files to expand CKAN.")
12 def generate():
13     pass
14 
15 
16 @generate.command(name=u'extension', short_help=u"Create empty extension.")
17 @click.option(u'-o', u'--output-dir', help=u"Location to put the generated "
18                                            u"template.",
19               default=u'.')
20 def extension(output_dir):
21     cur_loc = os.path.dirname(os.path.abspath(__file__))
22     os.chdir(cur_loc)
23     os.chdir(u'../../contrib/cookiecutter/ckan_extension/')
24     template_loc = os.getcwd()
25 
26     # Prompt user for information
27     click.echo(u"\n")
28     name = click.prompt(u"Extenion's name", default=u"must begin 'ckanext-'")
29     author = click.prompt(u"Author's name", default=u"")
30     email = click.prompt(u"Author's email", default=u"")
31     github = click.prompt(u"Your Github user or organization name",
32                           default=u"")
33     description = click.prompt(u"Brief description of the project",
34                                default=u"")
35     keywords = click.prompt(u"List of keywords (seperated by spaces)",
36                             default=u"CKAN")
37 
38     # Ensure one instance of 'CKAN' in keywords
39     keywords = keywords.strip().split()
40     keywords = [keyword for keyword in keywords
41                 if keyword not in (u'ckan', u'CKAN')]
42     keywords.insert(0, u'CKAN')
43     keywords = u' '.join(keywords)
44 
45     # Set short name and plugin class name
46     project_short = name[8:].lower().replace(u'-', u'_')
47     plugin_class_name = project_short.title().replace(u'_', u'') + u'Plugin'
48 
49     context = {u"project": name,
50                u"description": description,
51                u"author": author,
52                u"author_email": email,
53                u"keywords": keywords,
54                u"github_user_name": github,
55                u"project_shortname": project_short,
56                u"plugin_class_name": plugin_class_name,
57                u"_source": u"cli"}
58 
59     if output_dir == u'.':
60         os.chdir(u'../../../..')
61         output_dir = os.getcwd()
62 
63     if not name.startswith(u"ckanext-"):
64         print(u"\nERROR: Project name must start with 'ckanext-' > {}"
65               .format(name))
66         sys.exit(1)
67 
68     cookiecutter(template_loc, no_input=True, extra_context=context,
69                  output_dir=output_dir)
70
```
--- 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/ckan/cli/generate.py b/ckan/cli/generate.py
--- a/ckan/cli/generate.py
+++ b/ckan/cli/generate.py
@@ -4,13 +4,21 @@
 import sys
 import click
 from ckan.cli import error_shout
-from cookiecutter.main import cookiecutter
 
 
-@click.group(name=u'generate',
-             short_help=u"Generate empty extension files to expand CKAN.")
+@click.group(
+    name=u'generate',
+    short_help=u"Generate empty extension files to expand CKAN.",
+    invoke_without_command=True,
+)
 def generate():
-    pass
+    try:
+        from cookiecutter.main import cookiecutter
+    except ImportError:
+        error_shout(u"`cookiecutter` library is missing from import path.")
+        error_shout(u"Make sure you have dev-dependencies installed:")
+        error_shout(u"\tpip install -r dev-requirements.txt")
+        raise click.Abort()
 
 
 @generate.command(name=u'extension', short_help=u"Create empty extension.")
@@ -18,6 +26,7 @@
                                            u"template.",
               default=u'.')
 def extension(output_dir):
+    from cookiecutter.main import cookiecutter
     cur_loc = os.path.dirname(os.path.abspath(__file__))
     os.chdir(cur_loc)
     os.chdir(u'../../contrib/cookiecutter/ckan_extension/')

{"golden_diff": "diff --git a/ckan/cli/generate.py b/ckan/cli/generate.py\n--- a/ckan/cli/generate.py\n+++ b/ckan/cli/generate.py\n@@ -4,13 +4,21 @@\n import sys\n import click\n from ckan.cli import error_shout\n-from cookiecutter.main import cookiecutter\n \n \n-@click.group(name=u'generate',\n-             short_help=u\"Generate empty extension files to expand CKAN.\")\n+@click.group(\n+    name=u'generate',\n+    short_help=u\"Generate empty extension files to expand CKAN.\",\n+    invoke_without_command=True,\n+)\n def generate():\n-    pass\n+    try:\n+        from cookiecutter.main import cookiecutter\n+    except ImportError:\n+        error_shout(u\"`cookiecutter` library is missing from import path.\")\n+        error_shout(u\"Make sure you have dev-dependencies installed:\")\n+        error_shout(u\"\\tpip install -r dev-requirements.txt\")\n+        raise click.Abort()\n \n \n @generate.command(name=u'extension', short_help=u\"Create empty extension.\")\n@@ -18,6 +26,7 @@\n                                            u\"template.\",\n               default=u'.')\n def extension(output_dir):\n+    from cookiecutter.main import cookiecutter\n     cur_loc = os.path.dirname(os.path.abspath(__file__))\n     os.chdir(cur_loc)\n     os.chdir(u'../../contrib/cookiecutter/ckan_extension/')\n", "issue": "Missing dependency in requirements.txt (cookiecutter) \nhttps://github.com/ckan/ckan/blob/f2cea089bc0aaeede06d98449c4e9eb65e8c2f14/ckan/cli/generate.py#L7\r\n\r\n- cookiecutter lib will be imported on a `ckan` cli attempt, but as it is missing from requirments.txt, is not present which will result to ImportError \r\n\r\n- cookiecutter is listed in requirments-dev.txt, but docker builds don't use it\r\n\r\nTested on a docker personal build, by : \r\n> docker build -t ckan .\r\n> docker run --rm -it --entrypoint bash --name ckan -p 5000:5000 --link db:db --link redis:redis --link solr:solr ckan\r\n> (activated-env)\r\n> ckan\n", "before_files": [{"content": "# encoding: utf-8\n\nimport os\nimport sys\nimport click\nfrom ckan.cli import error_shout\nfrom cookiecutter.main import cookiecutter\n\n\n@click.group(name=u'generate',\n             short_help=u\"Generate empty extension files to expand CKAN.\")\ndef generate():\n    pass\n\n\n@generate.command(name=u'extension', short_help=u\"Create empty extension.\")\n@click.option(u'-o', u'--output-dir', help=u\"Location to put the generated \"\n                                           u\"template.\",\n              default=u'.')\ndef extension(output_dir):\n    cur_loc = os.path.dirname(os.path.abspath(__file__))\n    os.chdir(cur_loc)\n    os.chdir(u'../../contrib/cookiecutter/ckan_extension/')\n    template_loc = os.getcwd()\n\n    # Prompt user for information\n    click.echo(u\"\\n\")\n    name = click.prompt(u\"Extenion's name\", default=u\"must begin 'ckanext-'\")\n    author = click.prompt(u\"Author's name\", default=u\"\")\n    email = click.prompt(u\"Author's email\", default=u\"\")\n    github = click.prompt(u\"Your Github user or organization name\",\n                          default=u\"\")\n    description = click.prompt(u\"Brief description of the project\",\n                               default=u\"\")\n    keywords = click.prompt(u\"List of keywords (seperated by spaces)\",\n                            default=u\"CKAN\")\n\n    # Ensure one instance of 'CKAN' in keywords\n    keywords = keywords.strip().split()\n    keywords = [keyword for keyword in keywords\n                if keyword not in (u'ckan', u'CKAN')]\n    keywords.insert(0, u'CKAN')\n    keywords = u' '.join(keywords)\n\n    # Set short name and plugin class name\n    project_short = name[8:].lower().replace(u'-', u'_')\n    plugin_class_name = project_short.title().replace(u'_', u'') + u'Plugin'\n\n    context = {u\"project\": name,\n               u\"description\": description,\n               u\"author\": author,\n               u\"author_email\": email,\n               u\"keywords\": keywords,\n               u\"github_user_name\": github,\n               u\"project_shortname\": project_short,\n               u\"plugin_class_name\": plugin_class_name,\n               u\"_source\": u\"cli\"}\n\n    if output_dir == u'.':\n        os.chdir(u'../../../..')\n        output_dir = os.getcwd()\n\n    if not name.startswith(u\"ckanext-\"):\n        print(u\"\\nERROR: Project name must start with 'ckanext-' > {}\"\n              .format(name))\n        sys.exit(1)\n\n    cookiecutter(template_loc, no_input=True, extra_context=context,\n                 output_dir=output_dir)\n", "path": "ckan/cli/generate.py"}], "after_files": [{"content": "# encoding: utf-8\n\nimport os\nimport sys\nimport click\nfrom ckan.cli import error_shout\n\n\n@click.group(\n    name=u'generate',\n    short_help=u\"Generate empty extension files to expand CKAN.\",\n    invoke_without_command=True,\n)\ndef generate():\n    try:\n        from cookiecutter.main import cookiecutter\n    except ImportError:\n        error_shout(u\"`cookiecutter` library is missing from import path.\")\n        error_shout(u\"Make sure you have dev-dependencies installed:\")\n        error_shout(u\"\\tpip install -r dev-requirements.txt\")\n        raise click.Abort()\n\n\n@generate.command(name=u'extension', short_help=u\"Create empty extension.\")\n@click.option(u'-o', u'--output-dir', help=u\"Location to put the generated \"\n                                           u\"template.\",\n              default=u'.')\ndef extension(output_dir):\n    from cookiecutter.main import cookiecutter\n    cur_loc = os.path.dirname(os.path.abspath(__file__))\n    os.chdir(cur_loc)\n    os.chdir(u'../../contrib/cookiecutter/ckan_extension/')\n    template_loc = os.getcwd()\n\n    # Prompt user for information\n    click.echo(u\"\\n\")\n    name = click.prompt(u\"Extenion's name\", default=u\"must begin 'ckanext-'\")\n    author = click.prompt(u\"Author's name\", default=u\"\")\n    email = click.prompt(u\"Author's email\", default=u\"\")\n    github = click.prompt(u\"Your Github user or organization name\",\n                          default=u\"\")\n    description = click.prompt(u\"Brief description of the project\",\n                               default=u\"\")\n    keywords = click.prompt(u\"List of keywords (seperated by spaces)\",\n                            default=u\"CKAN\")\n\n    # Ensure one instance of 'CKAN' in keywords\n    keywords = keywords.strip().split()\n    keywords = [keyword for keyword in keywords\n                if keyword not in (u'ckan', u'CKAN')]\n    keywords.insert(0, u'CKAN')\n    keywords = u' '.join(keywords)\n\n    # Set short name and plugin class name\n    project_short = name[8:].lower().replace(u'-', u'_')\n    plugin_class_name = project_short.title().replace(u'_', u'') + u'Plugin'\n\n    context = {u\"project\": name,\n               u\"description\": description,\n               u\"author\": author,\n               u\"author_email\": email,\n               u\"keywords\": keywords,\n               u\"github_user_name\": github,\n               u\"project_shortname\": project_short,\n               u\"plugin_class_name\": plugin_class_name,\n               u\"_source\": u\"cli\"}\n\n    if output_dir == u'.':\n        os.chdir(u'../../../..')\n        output_dir = os.getcwd()\n\n    if not name.startswith(u\"ckanext-\"):\n        print(u\"\\nERROR: Project name must start with 'ckanext-' > {}\"\n              .format(name))\n        sys.exit(1)\n\n    cookiecutter(template_loc, no_input=True, extra_context=context,\n                 output_dir=output_dir)\n", "path": "ckan/cli/generate.py"}]}