oci-cli icon indicating copy to clipboard operation
oci-cli copied to clipboard

regression: oci ignores OCI_CLI_RC_FILE environment variable

Open brianredbeard opened this issue 1 year ago • 7 comments

The documentation for the OCI CLI states:

The default location and file name for the CLI-specific configuration file is ~/.oci/oci_cli_rc, but you can use the OCI_CLI_RC_FILE environment variable to modify where the CLI looks for a configuration file and its default values upon startup.

This is confirmed in CHANGELOG.rst for version 2.6.9

At the present time this fails as can be seen in the following example (attempting to use the FreeDesktop defined location):

❯ cat $OCI_CLI_RC_FILE
[DEFAULT]
user=ocid1.user.oc1.......
fingerprint=ba:03:ee:44:70:65:44:9c:ff:.....
key_file=/Users/bharrington/.local/share/oci/oci_api_key.pem
tenancy=ocid1.tenancy.oc1......
region=us-phoenix-1
pass_phrase="N/A"
❯ OCI_CLI_RC_FILE=/Users/bharrington/.config/oci oci os ns get
ERROR: Could not find config file at /Users/bharrington/.oci/config
Do you want to create a new config file? [Y/n]: 

brianredbeard avatar Apr 25 '23 00:04 brianredbeard

oci-cli uses two config files. The CLI documentation refers to ~/.oci/oci_cli_rc as the "CLI Configuration File". Elsewhere ~/.oci/config is called the "SDK and CLI Configuration file". Neither is particularly well documented. I think of the former as the "rc" file, and the latter as the "config" file.

User profiles (the "user =" and other login info shown above) are stored in the config file -- that is, in the file named "config". Command and parameter aliases (shortcuts) and some default settings are stored in the rc file.

I suspect the environment variable is successfully changing the rc file, but the cli is looking for user profile info in a config file and it can't find it. Move the user profile info to ~/.oci/config, or to a file identified in OCI_CLI_CONFIG_FILE, and the cli should work as expected.

kevco-us avatar Aug 14 '23 20:08 kevco-us

oci cli is not picking up export OCI_CLI_RC_FILE="~/rc_file"environment variable. But if I specify --cli-rc-file=~/rc_file on command line it works.

$ oci --version 3.33.2

spareslant avatar Oct 03 '23 13:10 spareslant

The quotes are preventing tilde expansion.
export OCI_CLI_RC_FILE=~/rc_file will work.

kevco-us avatar Oct 03 '23 13:10 kevco-us

The quotes are preventing tilde expansion. export OCI_CLI_RC_FILE=~/rc_file will work.

I have already tried full absolute path as well. Its not picking up.

spareslant avatar Oct 03 '23 14:10 spareslant

What OS are you using? Windows? Linux?

kevco-us avatar Oct 03 '23 15:10 kevco-us

MacOS Ventura 13.5.2

spareslant avatar Oct 03 '23 15:10 spareslant

Okay, I see what you mean. I finally tried using the OCI_CLI_RC_FILE variable in an oci command and it seems to be ignored.

kevco-us avatar Oct 03 '23 15:10 kevco-us