   # Applies the environment settings to a release
   @doc false
   @spec apply_environment(__MODULE__.t, Environment.t) :: Release.t
-  def apply_environment(%__MODULE__{profile: rel_profile} = r, %Environment{profile: env_profile}) do
+  def apply_environment(%__MODULE__{profile: rel_profile} = r, %Environment{profile: env_profile, name: env_name}) do
     env_profile = Map.from_struct(env_profile)
     profile = Enum.reduce(env_profile, rel_profile, fn {k, v}, acc ->
       case v do

      overlays: [],
      commands: [],
      overrides: []
    }

  @type t :: %__MODULE__{
    name: atom(),

        _   -> Map.put(acc, k, v)
      end
    end)
    %{r | :env => env_name, :profile => profile}
  end

  @doc false
