mkdocs-multirepo-plugin icon indicating copy to clipboard operation
mkdocs-multirepo-plugin copied to clipboard

Bash scripts not found

Open rob-mgm opened this issue 2 years ago • 0 comments
trafficstars

Hello,

Unfortunately, we ran into a problem when trying to use this great plugin in conjunction with Gradle, which is used to automate our builds - the bash scripts used to clone the repos and move them can no longer be found.

Our mkdocs.yml looks something like this:

site_name: Documentation

plugins:
  - multirepo:
      cleanup: true
      keep_docs_dir: false
      repos:
        - section: Repo
          import_url: 'ssh://[email protected]/project/repo.git?edit_uri=/blob/master/&docs_dir=docs/**&extra_imports=["README.md"]'

When creating a Python virtual environment, installing the requirements and running mkdocs build locally, everything works as expected.

However, when putting this in our Gradle config (using a Python Gradle plugin, but same results when not using plugin), we get the following error:

> Task :buildDocs FAILED
[python] /home/user/projects/docs/.gradle/python/bin/python3 -m mkdocs build
         INFO    -  Multirepo plugin importing docs...
         Traceback (most recent call last):
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/util.py", line 92, in execute_bash_script
             process = await asyncio.create_subprocess_exec(
           File "/usr/lib/python3.8/asyncio/subprocess.py", line 236, in create_subprocess_exec
             transport, protocol = await loop.subprocess_exec(
           File "/usr/lib/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
             transport = await self._make_subprocess_transport(
           File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
             transp = _UnixSubprocessTransport(self, protocol, args, shell,
           File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 36, in __init__
           File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport🔳 repo
             self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
           File "/usr/lib/python3.8/asyncio/unix_events.py", line 789, in _start
             self._proc = subprocess.Popen(
           File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
             self._execute_child(args, executable, preexec_fn, close_fds,
           File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
             raise child_exception_type(errno_num, err_msg, err_filename)
         FileNotFoundError: [Errno 2] No such file or directory: PosixPath('/home/user/projects/docs/build/temp_dir/repo')

         During handling of the above exception, another exception occurred:

         Traceback (most recent call last):
           File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
             return _run_code(code, main_globals, None,
           File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
             exec(code, run_globals)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs/__main__.py", line 361, in <module>
             cli()
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
             return self.main(*args, **kwargs)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/click/core.py", line 1078, in main
             rv = self.invoke(ctx)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/click/core.py", line 1688, in invoke
             return _process_result(sub_ctx.command.invoke(sub_ctx))
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
             return ctx.invoke(self.callback, **ctx.params)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/click/core.py", line 783, in invoke
             return __callback(*args, **kwargs)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs/__main__.py", line 286, in build_command
             build.build(cfg, dirty=not clean)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs/commands/build.py", line 277, in build
             config = config.plugins.on_config(config)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs/plugins.py", line 527, in on_config
             return self.run_event('config', config)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs/plugins.py", line 507, in run_event
             result = method(item, **kwargs)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/plugin.py", line 315, in on_config
             return self.handle_repos_import(config, repos)
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/plugin.py", line 238, in handle_repos_import
             asyncio_run(batch_import(docs_repo_objs))
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/util.py", line 114, in asyncio_run
             asyncio.run(futures)
           File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
             return loop.run_until_complete(main)
           File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
             return future.result()
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/structure.py", line 424, in batch_import
             await batch_execute(
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/structure.py", line 416, in batch_execute
             repo = await future
           File "/usr/lib/python3.8/asyncio/tasks.py", line 619, in _wait_for_one
             return f.result()  # May raise f.exception().
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/structure.py", line 390, in import_docs
             await execute_bash_script(
           File "/home/user/projects/docs/.gradle/python/lib/python3.8/site-packages/mkdocs_multirepo_plugin/util.py", line 101, in execute_bash_script
             raise GitException(
         mkdocs_multirepo_plugin.util.GitException: bash executable not found. Please ensure bash is available in PATH.

However, digging into the issue, the message does not seem to be appropriate. bash is available, the problem is that /home/user/projects/docs/build/temp_dir/repo cannot be accessed. This in turn seems to be caused by sparse_clone.sh not working as intended. If you log stderr of it's execution in util.py, you'll get the following error:

/usr/bin/bash: sparse_clone.sh: No such file or directory

So it seems that the bash scripts in scripts/ are not accessible in our setup. This can be confirmed by setting the absolute path to the scripts/ directory here, which works.

Does anyone have an idea what is going on here?

Setup:

  • Ubuntu WSL on Windows 10
  • Python 3.8.10, pip 23.2.1
  • mkdocs 1.5.3, mkdocs-multirepo-plugin 0.6.3
  • Gradle 7.3.2

rob-mgm avatar Sep 20 '23 10:09 rob-mgm