xg env deactivate
xg env deactivate
Section titled “xg env deactivate”Clears the currently active Dataverse environment from the local XrmGhost configuration. After a successful deactivation, no environment is set as active — subsequent commands that require an active environment (such as xg run) will prompt you to activate one first.
If no environment is currently active, the command reports that fact and exits successfully without making any changes.
License requirement: This sub-command requires an active Pro (or higher) subscription. Run
xg license statusto verify your current tier.
Synopsis
Section titled “Synopsis”xg env deactivateDescription
Section titled “Description”xg env deactivate reads the current active environment from the local configuration store (d365_environments.json). It then does one of the following:
- No environment is active — Prints a warning message (
No environment is currently active.) and exits with code0. This is a safe no-op; nothing is modified. - An environment is active — Clears the active environment pointer in the store and prints a confirmation message:
Environment '<FRIENDLY_NAME>' deactivated successfully. No environment is active.
The command takes no arguments and no flags beyond the standard --help global option. There is no confirmation prompt.
Options
Section titled “Options”xg env deactivate accepts no flags or arguments.
| Flag | Type | Default | Description |
|---|---|---|---|
--help | bool | false | Display help text for this command and exit. |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Command completed successfully — either the active environment was cleared, or no environment was active (no-op). |
1 | License tier insufficient (Pro required), or an unexpected internal error occurred. |
Examples
Section titled “Examples”Deactivate the currently active environment
Section titled “Deactivate the currently active environment”$ xg env deactivate
Environment 'Production' deactivated successfully. No environment is active.Run when no environment is active (no-op)
Section titled “Run when no environment is active (no-op)”$ xg env deactivate
No environment is currently active.The exit code is 0 in both cases. You can use this command in scripts without first checking whether an environment is active.
Typical workflow: deactivate, switch, re-activate
Section titled “Typical workflow: deactivate, switch, re-activate”# Deactivate the current environmentxg env deactivate
# Verify no environment is activexg env status
# Activate a different environmentxg env activate StagingSee Also
Section titled “See Also”xg env activate— Set a specific Dataverse environment as the active one.xg env list— List all registered Dataverse environments and see which one is currently active.xg env status— Show the active environment URL and name.- CLI Overview — Introduction to the XrmGhost CLI and its command groups.