Skip to main content

Fixed: "No Active Environment Set for the Current Auth Profile" in Power Platform CLI

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

The Power Platform CLI signed me in without a problem, and the very next command failed: No active environment set for the current auth profile. The sign-in had created a profile with no environment attached. One command, pac env select, fixed it.

What I Was Doing​

Part 12 of the Career Development Plan series uses the Power Platform CLI (pac) to export and check solutions. I installed it and signed in with a device code, without the --environment option (How to Sign In to the Power Platform CLI with pac auth create):

Terminal
pac auth create --deviceCode

The sign-in finished:

Output
'admin@example.com' authenticated successfully.
Authentication profile created
* UNIVERSAL : admin@example.com Public

What I Expected​

Microsoft's introduction to the CLI says that if you leave out --environment, you're connected to the default environment. My tenant has only one environment, its default one, so I expected the next command to use it.

What I Got​

I asked the CLI which environment it was connected to, with pac org who, the older name of pac env who:

Output
$ pac org who
Connected as admin@example.com
Microsoft PowerPlatform CLI
Version: 2.14.1+g6f517e5 (.NET 10.0.13)
Online documentation: https://aka.ms/PowerPlatformCLI
Feedback, Suggestions, Issues: https://github.com/microsoft/powerplatform-build-tools/discussions

Error: No active environment set for the current auth profile. Specify an environment via the `--environment` argument or use an auth profile with an active environment. Alternatively, you can use `pac org select` to set the active environment for the current auth profile.

pac env who gave the same error. The list of profiles showed why: the Environment and Environment Url columns were empty.

Output
$ pac auth list
Index Active Kind Name User Cloud Type Environment Environment Url ERP URL
[1] * UNIVERSAL admin@example.com Public User

What I Checked​

  • The pac auth create reference. Its --environment option sets the default environment of the new profile, as an ID, a URL, a unique name or part of a name (pac auth). I hadn't given one.
  • The pac env reference. Since version 1.32, pac org is called pac env; org still works (pac env). pac env select selects the default organization for the current authentication profile, and pac env list lists the environments you can choose from.
  • What the error itself suggests: --environment on each command, a profile that has an environment, or pac org select, the old name of pac env select.

Why It Happens​

A profile created without --environment here was a UNIVERSAL profile with no active environment, whatever the introduction's sentence suggests. Commands that work with an environment's data, such as pac env who or pac solution export, need one, so they stop until the profile has an environment or you name one with --environment.

The Fix​

1. List the environments​

Terminal
pac env list
Output
Connected as admin@example.com
Active Display Name Environment ID Environment URL Unique Name
Default Environment 00000000-0000-0000-0000-000000000000 https://org00000000.crm.dynamics.com/ unq00000000000000000000000000000000

The Active column is empty: none is selected. Note the display name of the one you want.

2. Select it​

Terminal
pac env select --environment "Default Environment"
Output
Connected as admin@example.com
Looking for environment ''Default Environment''
Validating connection...
Connected to... Default Environment
Selected org 'Default Environment' 'https://org00000000.crm.dynamics.com/' for current authentication profile.

Use your own environment's name, its URL or its ID. The name here is this tenant's default environment.

After the Fix​

pac env who now describes the environment:

Output
$ pac env who
Connected as admin@example.com
Connected to... Default Environment
Organization Information
Org ID: 00000000-0000-0000-0000-000000000000
Unique Name: unq00000000000000000000000000000000
Friendly Name: Default Environment
Org URL: https://org00000000.crm.dynamics.com/
User Email: admin@example.com
User ID: 00000000-0000-0000-0000-000000000000
Environment ID: 00000000-0000-0000-0000-000000000000

And the profile has it:

Output
$ pac auth list
Index Active Kind Name User Cloud Type Environment Environment Url ERP URL
[1] * UNIVERSAL admin@example.com Public User Default Environment https://org00000000.crm.dynamics.com/

Every command after that, from pac solution list to pac solution export, worked without --environment.

Do It in One Step Next Time​

The pac auth create reference lets you name the environment when you sign in, with --environment and the same kinds of values as pac env select. I fixed my profile afterwards, so that's the route I ran.

Common Mistakes​

MistakeWhat happensDo this instead
Signing in without --environmentThe profile has no active environmentRun pac env select once
Typing a name that isn't in pac env listThe CLI can't find the environmentCopy the display name, URL or ID from pac env list

Troubleshooting​

SymptomLikely causeFix
No active environment set for the current auth profileThe profile has no environmentpac env select --environment "<name>"
pac env list shows no environmentsThe account can't see any Dataverse environmentSign in with an account that's a member of one
A command works on the wrong environmentAnother profile or environment is activeCheck pac auth list and pac env who

FAQ​

What's the difference between pac org and pac env?​

Only the name. Microsoft renamed org to env in version 1.32 and recommends env; org still works, which is why the error message mentions pac org select.

Can I name the environment on a single command instead?​

Yes. Commands that work with an environment accept --environment, as the error message says. Selecting it once saves typing it every time.

Conclusion​

A profile made without --environment had no active environment, so every environment command stopped with No active environment set for the current auth profile. pac env list shows your environments, and pac env select --environment "<name>" attaches one to the profile for good.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.