Skip to main content
New Participant
Oct 9, 2023 1:11 PM UTC

Could not read environments config file ~.boxox_environments.json

Hi very new to CLI and Box. Trying to follow the “Use Box CLI with OAuth 2.0” guide and got this error when trying to define my environment using the command “box login -n <environment_name>”. I have checked the config file in the listed path and the config file is empty (not sure if it’s supposed to have content).

I successfully used the “box login -n <environment_name>” command the other day when trying to follow the guide however it does not work today. Searching online brought me to this forum post: boxcli error "Could not read environments config file" – Box Support however I am so new I don’t know how to download a new config file from the provided link to the developer console.

For now I will try to download new config file but does anyone have any idea why my config file would stop working in this manner?

Thank you.

    1 reply

    rbarbosa Box
    Developer Advocate
    Oct 10, 2023 6:21 PM UTC

    Hi @user104 , welcome to the forum!

    It looks like something is off with the environment settings…

    Try the configure:environments:get command:

    ❯ box configure:environments
    Manage your CLI environments
    
    USAGE
      $ box configure:environments:COMMAND
    
    COMMANDS
      configure:environments:add          Add a new Box environment
      configure:environments:delete       Delete a Box environment
      configure:environments:get          Get a Box environment
      configure:environments:set-current  Set your current Box environment to use
      configure:environments:switch-user  Switch the default Box user to run commands as
      configure:environments:update       Update a Box environment
    

    This will output the current configurations, and then use the other command to adjust the configurations.

    For example in my case I have one environment configured to use the JWT access:

    ❯ box configure:environments:get
    Default:
        Client ID: febb9yq9nidfszj63ylzshqf2cg4emso
        Enterprise ID: '877840855'
        Box Config File Path: /Users/rbarbosa/Documents/box-cli/jwt.config.json
        Has Inline Private Key: true
        Private Key Path: null
        Name: default
        Default As-User ID: null
        Use Default As-User: false
        Cache Tokens: true
    

    Set as current:

    ❯ box configure:environments:set-current
    ? Which environment? (Use arrow keys)
    ❯ default
    

    Let us know if this helps

    Translate