New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while executing gh-deploy #722
Comments
So, this sounds like we might have hit an issue related to #703 - I think we are passing unicode to an API that expects a bytestring? |
That sounds weird. All of my md files are in UTF-8 and it worked the first time i published the site to gh-pages. |
@ThomasArdal, I don't think he was referring to the content of your md files, but the encoding of the arguments getting passed from command line or encoding between methods internally. |
Sorry, I was too vague. I am lagging after travelling and was trying to be too lazy 😀 I can't account for why this worked and then didn't. Other than maybe it always works for the first deploy and the issue is to do with the code that is different in subsequent deploys? The cause of the problem does seem to be internal and not related to your files. Given you are on Windows I suspect it will be related to that. |
@d0ugal Anyway I can debug what's going on here? Or maybe use some other mkdocs commands to eliminate stuff. |
@ThomasArdal looking at the traceback, the error is definitely within the gh-deploy code (therefore other commands won't exhibit the problem). The code builds up a git command as a string, then calls a subprocess passing in that command. The encoding issue appears to be with that command string. I have two things you can check:
I suspect the improperly encoded string is coming from one of those two places. In the first case, a config setting or in the second case, a default value defined in the code. |
I tried commenting the line from future import unicode_literals and installed the code. still the same error. Isn't this a showstopper? can someone help to clear this? |
I guess a workaround is to build the site, make a copy of the output, switch to the gh-pages branch, paste the content and push the changes. But being able to do this with a single command would be way more sweet. |
I spent a bit of time looking into this, the problem I have is that I am not able to reproduce it. We don't have anyone working on MkDocs that uses windows, so tracking these things down can be tricky. |
I was able to spend a little bit of time on a Windows box yesterday and was not able to reproduce it there either. Although, that box only had Python 2.7 installed. Afterward, I noticed that the error was reported in Python 3.4... Which is weird. If the error is in Python 3 then I expect that it would not be related to |
I tried downgrading to Python 2.7.10 and it turns out that the bug is not there anymore. Success. I'm able to re-create the bug on a new repository with Python 3.4.x. First time I run a gh-deploy, everything works fine. The second time I run With Python 2.7.10, I still get a warning though. Seems to be related to the previous bug: C:\Python27\lib\site-packages\mkdocs\cli.py:86: Warning: Click detected the use of the unicode_literals future import. This is heavily discouraged because it can introduce subtle bugs in your code. You should instead use explicit u"" literals for your unicode strings. For more information see http://click.pocoo.org/python3/ |
Great, good to know 2.7 works. So I think that suggests we have a Python 3 bug on windows. That warning should be safe to ignore, it will be disabled in the next release. |
Yes, that warning was addressed in #703. However, as you state, the bug doesn't exist in Python 2.7 (where unicode_literals matters) so I think that is a red herring in the case. Just to be sure though, try commenting out/removing the
I would be surprised if that fixes the issue, but it would be helpful to know either way so we can focus on the actual problem. |
had exactly that same issue with python 3.5 |
I jut took another look at this. Again, not being able to reproduce it, its difficult to narrow down. In any event, I found this, which looks somewhat related. Interestingly, a comment points to a change in Python 3.2 which caused previously working code to break. While that was regarding gzip, and this is regarding subprocess, its entirely possible that a similar change in 3.5 is causing the problem. What I know for sure is that something being passed to subprocess is a Unicode string and needs to be a bytestring (but apparently only in Python >= 3.5). Unfortunately, without the ability to replicate it (no access to Python 3 on Windows), I have no way of determining what that is. If you'd like this fixed, I'd recommend trying to force the pieces passed to the ghp_import tool to bytestring and see if the problem goes away (probably something in |
To be more precise, I expect one or more of the variables passed in on L68-69 (probably |
I believe the problem actually lies with p.communicate() (on Python 3) returning bytes unless the Popen object has |
Interesting. It does use universal_newlines on one of the Popen calls. We can add it to the others. https://github.com/mkdocs/mkdocs/blob/master/mkdocs/utils/ghp_import.py#L144 |
I pushed a fix to #881. However, as I have no way to test it, we'll need someone who has the problem to apply the patch and verify the problem is fixed before accepting it. |
@waylan I can test this next week if you'd like? |
@ThomasArdal any success with your tests? |
@waylan Looking at it now. |
@waylan Doesn't seem like I can checkout the pull request. I've tried checkout out your clone, but I'm not sure what to do to test it. I'm not a Python expert, but would love to help testing this. Could you maybe build a package or show me how? |
This command should download and install it for you:
|
@waylan When trying to install, I get the following error:
|
Did you notice the second and third lines:
See if that makes a difference. Or, if you already have a git checkout, you could just run |
I've done the following, but still didn't manage to test this:
Now I get the following error:
|
Hmm, I was just able to test this on Windows 7 with Python 3.5 and could not reproduce the reported problem. I used the following commands to ensure a clean/fresh start (using my personal fork of MkDocs and the MkDocs documentation): git push origin --delete gh-pages
git branch -D gh-pages
mkdocs gh-deploy --clean
# edit docs/index.md ...
mkdocs gh-deploy --clean Everything ran fine without applying the changes in #881. Note that I first ensured any |
Okay, I feel dumb now. I was using Python2 in my last comment. Once I forced Python3 ( |
@waylan Oh no |
Fixes mkdocs#722. See also c-w/ghp-import#52
Okay, once i was able to replicate the problem myself, the fix was easy. After I figured it out, then I found c-w/ghp-import#52 which is (mostly) doing the same thing. Once the CI tests pass, I'll commit #904. |
👍 |
I had the same problem, and I can confirm the bug is solved in the current master (https://github.com/mkdocs/mkdocs/tree/5713289658701b3ab80e5975f9825955403eecfb) 👍 Thanks for solving this. I lost several hours trying to figure out what was wrong. |
Thanks all! I am use python 2.7 instead of 3.5 and it finally works with my windows 7. Really appreciate you all! |
I've successfully deployed a MkDocs site using the gh-deploy command. When I try to deploy some additional changes to my master branch, I get the following error:
The text was updated successfully, but these errors were encountered: