{"id":4144,"library":"oci-cli","title":"Oracle Cloud Infrastructure CLI","description":"The Oracle Cloud Infrastructure CLI (oci-cli) is a command-line interface that allows users to interact with Oracle Cloud Infrastructure services. Built on the OCI Python SDK, it provides equivalent functionality to the OCI Console, plus additional commands and scripting capabilities. The current version is 3.78.0, and it is actively maintained by Oracle with frequent updates and new feature releases.","status":"active","version":"3.78.0","language":"python","source_language":"en","source_url":"https://github.com/oracle/oci-cli","tags":["oracle cloud","oci","cli","cloud management","sdk","infrastructure-as-code"],"install":[{"cmd":"pip install oci-cli","lang":"bash","label":"Install the CLI via pip (recommended for Python environments)"},{"cmd":"bash -c \"$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)\"","lang":"bash","label":"Installer script for Linux/Unix (includes dependencies)"}],"dependencies":[{"reason":"The core Oracle Cloud Infrastructure Python SDK, which the CLI is built upon.","package":"oci","optional":false},{"reason":"Used for secure communications and API key management.","package":"cryptography","optional":false},{"reason":"Used for parsing and managing configuration files.","package":"PyYAML","optional":false},{"reason":"Used for powerful JSON querying capabilities, especially with the `--query` flag.","package":"jmespath","optional":false}],"imports":[{"note":"While `oci-cli` is the installed package, the underlying Python SDK for programmatic interaction is imported as `oci`. Do not attempt to import modules directly from `oci_cli` as it primarily contains CLI internals.","wrong":"import oci_cli","symbol":"oci","correct":"import oci"}],"quickstart":{"code":"# First, ensure your OCI configuration file (~/.oci/config) is set up.\n# You can generate one interactively using: oci setup config\n#\n# Then, use the OCI Python SDK (installed with oci-cli):\n\nimport oci\nimport os\n\n# Load the OCI config from the default location and profile\n# (or specify path and profile like oci.config.from_file(\"/path/to/config\", \"YOUR_PROFILE\"))\ntry:\n    config = oci.config.from_file(os.environ.get('OCI_CONFIG_FILE', '~/.oci/config'), os.environ.get('OCI_PROFILE', 'DEFAULT'))\nexcept oci.exceptions.ConfigFileNotFound as e:\n    print(f\"Error: OCI config file not found. Please run 'oci setup config' or set OCI_CONFIG_FILE and OCI_PROFILE environment variables. {e}\")\n    exit(1)\n\n# Create an IdentityClient\nidentity_client = oci.identity.IdentityClient(config)\n\n# Get the tenancy OCID from the config\ntenancy_id = config[\"tenancy\"]\n\n# List compartments in the tenancy\ntry:\n    list_compartments_response = identity_client.list_compartments(compartment_id=tenancy_id, compartment_id_in_subtree=True)\n    print(\"Listing Compartments:\")\n    for compartment in list_compartments_response.data:\n        print(f\"  Name: {compartment.name}, ID: {compartment.id}, Lifecycle State: {compartment.lifecycle_state}\")\nexcept oci.exceptions.ServiceError as e:\n    print(f\"Error listing compartments: {e}\")\n    if e.code == 'NotAuthenticated':\n        print(\"Please check your API key and fingerprint in ~/.oci/config.\")\n    elif e.code == 'AuthRequired':\n        print(\"Authentication failed. Ensure your API key is correctly configured and has necessary permissions.\")\n\n","lang":"python","description":"This quickstart demonstrates how to use the underlying OCI Python SDK to list compartments within your Oracle Cloud Infrastructure tenancy. Before running, ensure you have configured your OCI CLI by running `oci setup config` in your terminal to create the `~/.oci/config` file and API keys. The script loads this configuration for authentication."},"warnings":[{"fix":"Consult the `CHANGELOG.rst` or GitHub release notes for the specific version you are upgrading to and update your scripts/commands accordingly. Example: `--software-source-ids` became a required parameter in `oci os-management-hub profile create-software-source-profile` in a recent update.","message":"Breaking changes occur frequently in new releases, often involving parameter renames, commands being moved, or parameters becoming required. Always review the GitHub releases page or `CHANGELOG.rst` before upgrading major or minor versions.","severity":"breaking","affected_versions":"All versions (check release notes for specific changes)"},{"fix":"Replace `--defaults-file` with `--cli-rc-file` in your CLI commands and scripts.","message":"The `--defaults-file` CLI option is deprecated. Use `--cli-rc-file` instead for specifying CLI-specific configuration files.","severity":"gotcha","affected_versions":"All versions where `--defaults-file` is used"},{"fix":"Migrate all ML application instances to use Oracle Cloud Infrastructure Identity and Access Management (IAM) for authentication and authorization.","message":"OCI Data Science is deprecating Oracle Identity Cloud Service (IDCS) authentication for ML Applications. After April 11, 2026, deployments using IDCS-based authentication will not be supported, and new ML application instances cannot be created using IDCS.","severity":"breaking","affected_versions":"ML Application instances using IDCS authentication, effective April 11, 2026"},{"fix":"Run `oci setup config` to generate the configuration file and API keys. Ensure the public key is uploaded to your OCI user in the Console, and the private key file path and fingerprint in `~/.oci/config` are correct and accessible.","message":"The OCI CLI (and SDK) requires a properly configured `~/.oci/config` file and corresponding API key pair for authentication. Incorrect setup or permissions is a common source of errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with JMESPath (jmespath.org). For large datasets, consider using `--filter` with SCIM expressions (which might use different attribute names than the CLI output) alongside `--query` to reduce client-side processing.","message":"When querying JSON output with `--query`, the argument uses JMESPath syntax. This is powerful but can be unfamiliar and requires understanding JMESPath expressions for effective filtering and transformation. Using `--filter` provides SCIM-based filtering *before* `--query` is applied.","severity":"gotcha","affected_versions":"All versions using `--query`"}],"env_vars":null,"search_vec":"'3.78.0':53 'activ':57 'addit':44 'allow':20 'built':29 'capabl':48 'cli':4,9,12,71 'cloud':2,7,26,69,72 'code':78 'command':16,45 'command-lin':15 'consol':42 'current':50 'equival':37 'featur':66 'frequent':62 'function':38 'infrastructur':3,8,27,76 'infrastructure-as-cod':75 'interact':23 'interfac':18 'line':17 'maintain':58 'manag':73 'new':65 'oci':11,32,41,70 'oci-c':10 'oracl':1,6,25,60,68 'plus':43 'provid':36 'python':33 'releas':67 'script':47 'sdk':34,74 'servic':28 'updat':63 'user':21 'version':51","created_at":"2026-04-12T03:42:50.738659+00:00","updated_at":"2026-04-16T17:30:53.598492+00:00","problems":[{"fix":"Ensure the OCI CLI is installed in an accessible location and its executable directory (e.g., `~/bin` or Python's `Scripts` directory on Windows) is included in your system's PATH. If using a virtual environment, activate it. On Windows, you might need to add `C:\\Users\\<username>\\AppData\\Roaming\\Python\\Scripts` to your PATH.","cause":"The 'oci' executable is not in your system's PATH environment variable, or the OCI CLI was not installed correctly or in an active virtual environment.","error":"oci: command not found"},{"fix":"Run `oci setup config` to reconfigure your CLI. Verify that your `~/.oci/config` file contains the correct `user`, `fingerprint`, `key_file` path, `tenancy`, and `region`. Ensure the private key file has appropriate permissions (e.g., `600`) and the corresponding public key is uploaded to your OCI user's API Keys in the OCI Console.","cause":"This error typically indicates that the OCI CLI cannot authenticate due to an invalid or incomplete configuration file, incorrect API key details (user OCID, tenancy OCID, fingerprint, key file path), or a mismatch between the local private key and the public key uploaded to OCI.","error":"ServiceError: { \"code\": \"NotAuthenticated\", \"message\": \"The required information to complete authentication was not provided.\", \"status\": 401 }"},{"fix":"Check if the `~/.oci/config` file exists in the expected location (e.g., `/home/user/.oci/config` on Linux/macOS or `C:\\Users\\<username>\\.oci\\config` on Windows). If not, run `oci setup config` to create it. Ensure the `.oci` directory and `config` file have restrictive permissions (e.g., `chmod 700 ~/.oci` and `chmod 600 ~/.oci/config`).","cause":"The OCI CLI cannot locate its configuration file at the default or specified path, often due to an incorrect path, the file not existing, or improper permissions preventing access.","error":"ERROR: Could not find config file at /root/.oci/config"},{"fix":"Verify that the resource OCID is correct and that the resource exists. Review your IAM policies in the OCI Console to ensure your user or group has the required permissions for the operation and the resource's compartment. If accessing a resource in a specific compartment, confirm the compartment ID is correct.","cause":"This error means the authenticated user either lacks the necessary IAM permissions (policy statements) to perform the requested operation on the specified resource, or the resource itself does not exist (e.g., incorrect OCID, wrong compartment).","error":"ServiceError: { \"code\": \"NotAuthorizedOrNotFound\", \"message\": \"Authorization failed or requested resource not found.\", \"status\": 404 }"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.91.0","cli_name":"oci","cli_version":"3.82.0","type":"library","homepage":"https://docs.cloud.oracle.com/iaas/Content/API/Concepts/cliconcepts.htm","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/oci-cli/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}