Closed EDIflyer closed 2 years ago
I am having similar issues. Looks like the plugin wasn't playing well with newer versions of Git inside the container.
You may want to try the following:
pip
installation of Material for MkDocs8.2.1
Interesting. Thanks for the report & the research.
Does the suggestion git config --global --add safe.directory /docs'
fix the problem?
If so, I could ask mkdocs-material to update the docker image, and on my end update the installation instructions when used within docker images.
Thanks both - @timvink am I correct in thinking that this command would be something I need to run within the Docker container?
I am able to reproduce the error:
mkdir testmkdocsdocker
cd testmkdocsdocker
mkdocs new .
# enable mkdocs-material theme and this plugin in mkdocs.yml
Then use the docker image by creating a Dockerfile
FROM squidfunk/mkdocs-material
RUN pip install mkdocs-git-revision-date-localized-plugin
And run docker build -t squidfunk/mkdocs-material .
to build it locally.
Then
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material
Gives me:
stderr: 'fatal: unsafe repository ('/docs' is owned by someone else)
To add an exception for this directory, call:
git config --global --add safe.directory /docs'
To solve this, I changed the Dockerfile
to:
FROM squidfunk/mkdocs-material
RUN pip install mkdocs-git-revision-date-localized-plugin
RUN git config --global --add safe.directory /docs
Rebuilt it (docker build -t squidfunk/mkdocs-material .
), and ran it again, now with success!
So, to close this issue, I will do two things:
1) Provide a PR to mkdocs-material
to update the docs (because this applies to all git-based plugins)
2) Update the setup instructions of this plugin.
Thanks, @timvink - your errors seem to be slightly different to the ones I was getting though?
today at 12:34:46 git config --global --add safe.directory /docs'
today at 12:41:59INFO - Building documentation...
today at 12:41:59WARNING - Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server instead.
today at 12:41:59ERROR - [git-revision-date-localized-plugin] Unable to read git logs of '/docs/docs'. To ignore this error, set option 'fallback_to_build_date: true'
I've realised mine already includes the 'add safe directory' bit - although is that '
at the end maybe an issue? Also mind refers to /docs/docs
?
Will there be a way for mkdocs-materials
to be updated so it doesn't require a separate Dockerfile or was the intention always that you would need to create a custom Dockerfile with the pip install command?
Thanks 😃 (and appreciate I may be totally off base as have only been learning Docker for the past week!)
EDIT: I see suggestion no 2 in the issue you just opened on mkdocs-material deals with the Dockerfile issue - you're way ahead of me!!
your errors seem to be slightly different to the ones
Nope, same error, I just copied the last bit for brevity.
I've realised mine already includes the 'add safe directory' bit - although is that ' at the end maybe an issue? Also mind refers to /docs/docs?
Yeah the error message include the trailing '
which is wrong. Try updating your Dockerfile
with the example I gave.
Will there be a way for mkdocs-materials to be updated so it doesn't require a separate Dockerfile
You'll always have to install your packages separately (to keep the mkdocs-material
image as small as possible). Hopefully we can solve this setup problem in the base image though.
@EDIflyer I think your log in the OP includes two separate runs and somehow they are not in chronological order and get mixed. Please note the timestamp.
I've realised mine already includes the 'add safe directory' bit
Indeed it hasn't. The line today at 12:34:46 git config --global --add safe.directory /docs'
is actually the very end part of your previous run. Git was suggesting you issue the command, which means, you haven't yet done so.
As for the '
I don't think it's the problem. They are misleading but correctly in pair.
the opening one
|
today at 12:41:59 stderr: 'fatal: unsafe repository ('/docs' is owned by someone else)
today at 12:41:59To add an exception for this directory, call:
today at 12:41:59
today at 12:41:59 git config --global --add safe.directory /docs'
|
the closing one
Thanks @timvink so I rebuilt the Dockerfile as suggested and indeed no errors now 👍
I wonder if the documentation needs updated to clarify how the plugin is supported in mkdocs-material as when I first read this I hadn't realised I needed to do a new Dockerfile:
My next issue is to try and work out why it's reporting a date from a couple of days ago rather than today's date when using git_revision_date_localized
!
Will also have a play about with options now for getting non-US date format and automatically including on pages but at least seems to be up and running now 😃
https://github.com/squidfunk/mkdocs-material/pull/4118 will address this issue when accepted, so closing this issue.
I wonder if the documentation needs updated to clarify how the plugin is supported in mkdocs-material
Fair point, you might want to open an issue with mkdocs-material
.
My next issue is to try and work out why it's reporting a date from a couple of days ago rather than today's date
Remember this plugin does reporting the last file edit date, rather the last file commit date. Did you make a commit for today's changes?
Will also have a play about with options
Have fun :)
Thanks, @timvink - it was this bit on your documentation at https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/ that I thought might be worth tweaking?
I appreciate it was my own fault for not understanding, but I read it at first that the plugin was supported by mkdocs-material
, I then thought I should try to activate it in plugins without realising it needing installed too. Would it be worth changing the text as follows (bold bit):
The mkdocs-material theme has built in support for
git-revision-date-localized
and you should already see the last revision date on the bottom of your pages once you have activated the plugin as noted above.
Also for the install bit above would it be worth adding a comment with that Dockerfile you helpfully provided above?
Totally appreciate in retrospect how obvious this probably is, but when I came fresh to it a couple of days ago I hadn't quite appreciate the process!
Totally appreciate in retrospect how obvious this probably is, but when I came fresh to it a couple of days ago I hadn't quite appreciate the process!
Yeah it's hard to write documentation trying to image how to come to this fresh. If you have any improvements to the docs of this plugin I'd appreciate a PR!
PR #94 created - sorry also stupidly hadn't realised the docs were in the repo - got too used to seeing the edit icon in mkdocs-material 😂 Also added a bonus PR #95 re locale.
Thanks for creating this plugin, it looks great! I'm running mkdocs-material in Docker but unfortunately I'm not having any success running the plugin so far.
I saw in the documentation that it was built-in to mkdocs-material, however when I tried to add
This page was last updated: *{{ git_revision_date_localized }}*
text to a page it didn't get parsed and just came through as-is.I then tried to add
to my mkdocs.yml, but this led to an
ERROR - Config value: 'plugins'. Error: The "git-revision-date-localized" plugin is not installed
error message.I then created a new Dockerfile with
pip install mkdocs-git-revision-date-localized-plugin
included in the build and tried again but this time got the following error:My markdown files are stored in a docs subdirectory of my git repository and everything builds fine if I don't enable the plugin, so as far as I can tell I've got things mapped OK?