Power Apps environment variables a recently launched preview functionality that provide a way containing a dictionary set within a solution look to have a bit of a bug or undocumented limitation with managed solutions currently in the preview you should be aware of.

If you add an environment variable to a solution, including or not including a value then export it as managed, import the managed solution to another environment, you may notice that the environment variable isn’t actually listed in the solution itself. If you browse to the default solution and filter for environment variable component types the environment variable is there, shows as a managed component but the solution association is lost.

This has a downward effect of if you go about trying to remove your managed solution with an environment variable, because of the environment variable component association being lost from the solution, you will get the following error:

During Solution Uninstall of Solution Id {YOUR_SOLUTION_GUID}, cannot find any instances of the component with Component Id {YOUR_COMPONENTS_ID} and Component Type 380.

Error on remove of managed solution that includes an environment variable definition.

Component Type 380 is an Environment Variable Definition. For reference Component Type 381 is an Environment Variable Value.

Yikes you are now stuck with this solution that can’t be removed from your environment.

Creating a new version of the managed solution without the environment variable to try and remove it won’t help either. Installing that new version will fail again because when it tries to remove that component it will fail due to the lost solution association.

How you can remove the solution is by first deleting the environment variable from the default solution, then you will be able to remove the solution that included the environment variable component. It’s a little odd you can delete a managed component without doing a solution removal, odd as in you shouldn’t be able to normally do this, but this is a preview so there is the potential for items like this to occur.

If you are using environment variables this is an important bug that should be resolved and limitation to be aware of for now. Hopefully we will see an update to the preview that fixes this.