AWSCLI SyntaxError: Non-ASCII character '\xc3' error

I am working on a Ruby on Rails project where AWSCLI is used. Recently, When I push my code to Staging, it tries to import newkeys, PrivateKey, PublicKey from rsa.key and throws an error.

Error message is as follows:

SyntaxError: Non-ASCII character ‘\xc3’ in file /opt/circleci/.pyenv/versions/2.7.12/lib/python2.7/site-packages/rsa/key.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

My circleci/config.yml file is as follows:

orbs:
   aws-ecr: circleci/aws-ecr@7.0.0

version: 2.1

jobs:
  build:
    working_directory: ~/mfds
    docker:
      - image: circleci/ruby:2.3.4-node
      environment:
        RAILS_ENV: citest
        LANG: C.UTF-8
      - image: snowhork/mysql_jp:5.7
        environment:
          MYSQL_ROOT_PASSWORD: ***
          MYSQL_DATABASE: myapp
          MYSQL_USER: user
          MYSQL_PASSWORD: ***
          MYSQL_ROOT_HOST: "%"

  steps:
    - checkout
    - restore_cache:
      key: gemfiles-{{ checksum "mfds/Gemfile.lock" }}

  # Bundle install dependencies
  - run: cd mfds/ && bundle install --path vendor/bundle

  # Store bundle cache
  - save_cache:
      key: gemfiles-{{ checksum "mfds/Gemfile.lock" }}
      paths:
        - /home/circleci/mfds/mfds/vendor/bundle

  - run:
      name: Wait for db
      command: dockerize -wait tcp://localhost:3306 -timeout 1m

  # Database setup
  - run:
      name: db setting
      command: |
        cd mfds
        bundle exec rake db:create
        bundle exec rake db:ridgepole:apply[citest]

  - run:
      name: rspec
      command: |
        cd mfds
        bundle exec rspec

  staging_deploy:
    machine: true
    steps:
      - checkout
      - run:
        name: asset compile
        command: |
          cd mfds
          npm install
          ./node_modules/.bin/webpack --optimize-minimize

     - run:
      name: gem install
      command: |
        gem install aws-sdk-ecs
        pip install futures
        pip install --upgrade awscli

    - run:
      name: push image
      command: |
        export AWS_ACCESS_KEY_ID=$XX_AWS_ACCESS_KEY_ID
        export AWS_SECRET_ACCESS_KEY=$XX_AWS_SECRET_ACCESS_KEY
        bin/deployv2/docker-push staging

    - run:
      name: update service
      command: |
        export AWS_ACCESS_KEY_ID=$XX_AWS_ACCESS_KEY_ID
        export AWS_SECRET_ACCESS_KEY=$XX_AWS_SECRET_ACCESS_KEY
        bin/deployv2/update-task staging
   ....

I don’t understand how to resolve this problem.

Hi @micheldas1,

The config file you posted is fairly large and also looks to be edited and malformed so it’s a little hard to come to conclusions about what exactly is going on, especially without access to your code.

I would recommend trying to reproduce the problem slowly by building up an example config file that’s safer to post in full somewhere as well as full logs. Using the CCI CLI would be a convenient way to do that.

My initial thought, though, just as a wild guess, is that your caches are bad in some way and need to be blown. Adding something like *-v1-* to your cache keys would do that and also give you a way to blow these caches going forward by simply incrementing that number. But again, that’s kind of a wild guess.

Good luck!