Rju
Rju

Reputation: 63

Google cloud build trigger static site: 'ascii' codec can't encode characters

My building process for the static site is as follows:

  1. I create the public folder
  2. I copy the public folder and rename to gzipped.
  3. On the gzipped folder I run following code: find . -type f -exec gzip "{}" \; -exec mv "{}.gz" "{}" \;
  4. Then I push my repo and the build is automatically triggered.

When I include a € character in my .md file like following, then I get below error. Apparently it does not like special characters written like so - €1000 in my .md file (I guess the dash - is the culprit):

tags:
- tag1
- €1000
- tag2
- tag3

Here the error: Step #4: Caught non-retryable exception while listing file://./gzipped: 'ascii' codec can't encode characters in position 10-12: ordinal not in range(128) Step #4: CommandException: Caught non-retryable exception - aborting rsync.

How to fix my tags listing with an € in front of a dash?

Upvotes: 1

Views: 367

Answers (1)

mhouglum
mhouglum

Reputation: 2593

When you say "push to my repo", I assume you're using the gsutil rsync command, mostly due to the error message you're getting, which comes from this line of code:

https://github.com/GoogleCloudPlatform/gsutil/blob/65d6a3e30e2ad51279841a8b58008a5396568ddd/gslib/commands/rsync.py#L645

Glancing at the code there, I'm not sure why gsutil would be trying to use the ASCII codec. My two best guesses are:

  • Maybe you're running an old version of gsutil that has some encoding bugs? You can run gsutil version to check.
  • Maybe you're running this in a terminal/environment that uses ASCII (or something that doesn't support unicode characters) as its default encoding? I'm assuming from the find command that you're running on a Linux or macOS system -- if so, from your shell, you can check what Python thinks the default encoding is with:
$ python -c "import locale; print(locale.getdefaultlocale())"

This is emitted in my terminal, which uses UTF-8 as the default encoding:

('en_US', 'UTF-8')

Finally, if that isn't helpful, you'll probably want to get a bit more info than just the summary text shown in your error message - you could try adding in some extra print statements near the line I linked above, in your local gsutil installation (in the <path-to-gsutil>/gslib/commands/rsync.py file). Ideally, you'd want to view the whole stack trace to see where the error came from, so adding something like print(traceback.format_exc()) in the body of that except: block would be useful.

Upvotes: 1

Related Questions