OCI CLI Fails If Environment Variables "LC_ALL" and "LANG" Is Not Set — Cloud Customer Connect
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register
Note!! Please register for a free account to access the full content and also to participate in Q&A in the community
Get Started with Redwood: Oracle Cloud SCM and Purchasing

OCI CLI Fails If Environment Variables "LC_ALL" and "LANG" Is Not Set

edited Mar 29, 2023 11:06AM in Linux

Applies to

Oracle Cloud Infrastructure

Linux x86-64


Symptoms

Accessing OCI Bucket using oci cli works on interactive session but fail if run from cron with error:

RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. 
Consult https://click.palletsprojects.com/python3/ for mitigation steps.


Cause

OCI CLI is a Python3 script that uses Click.

Click requires "LC_ALL" and "LANG" environment variables to be set.


Solution

Define the environment variable in the script run by cron.

For example, if using bash, use:

#!/bin/bash
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!