Repository: facebookresearch/hydra

Issue:
[Bug] Cannot add a value to hydra.job.set_env from the command line.
# 🐛 Bug
## Description
I cannot add a append a config value for the hydra configuration (hydra installed from source)

## To reproduce


**Minimal Code/Config snippet to reproduce**


```
python main.py +hydra.job.env_set.WANDB_NOTES="X"
```

**Stack trace/error message**
```
Error merging override +hydra.job.env_set.WANDB_NOTES="X"
Key 'WANDB_NOTES' is not in struct
	full_key: hydra.job.env_set.WANDB_NOTES
	reference_type=Dict[str, str]
	object_type=dict
```

## Additional context
- I don't have the issue with `+` on non hydra config
- if I add `hydra.job.env_set.WANDB_NOTES=""` in the config then I can correctly override the value (without `+`)


## System information
- **Hydra Version** :  1.0.0rc2
- **Python version** : 3.8.5
- **Operating system** : Ubuntu 18.04.3 LTS





Discussion:
Thanks for reporting. for now set it in your config.

Patch:
diff --git a/hydra/_internal/config_loader_impl.py b/hydra/_internal/config_loader_impl.py
--- a/hydra/_internal/config_loader_impl.py
+++ b/hydra/_internal/config_loader_impl.py
@@ -265,7 +265,6 @@ def _load_configuration(
             )
             raise ConfigCompositionException(msg) from e
 
-        OmegaConf.set_struct(cfg.hydra, True)
         OmegaConf.set_struct(cfg, strict)
 
         # Apply command line overrides after enabling strict flag


Test patch:
diff --git a/hydra/test_utils/test_utils.py b/hydra/test_utils/test_utils.py
--- a/hydra/test_utils/test_utils.py
+++ b/hydra/test_utils/test_utils.py
@@ -15,7 +15,7 @@
 from subprocess import PIPE, Popen, check_output
 from typing import Any, Dict, Iterator, List, Optional, Union
 
-from omegaconf import DictConfig, OmegaConf
+from omegaconf import Container, DictConfig, OmegaConf
 from typing_extensions import Protocol
 
 from hydra._internal.hydra import Hydra
@@ -254,7 +254,7 @@ def _get_statements(indent: str, statements: Union[None, str, List[str]]) -> str
 
 def integration_test(
     tmpdir: Path,
-    task_config: DictConfig,
+    task_config: Any,
     overrides: List[str],
     prints: Union[str, List[str]],
     expected_outputs: Union[str, List[str]],
@@ -266,7 +266,7 @@ def integration_test(
     Path(tmpdir).mkdir(parents=True, exist_ok=True)
     if isinstance(expected_outputs, str):
         expected_outputs = [expected_outputs]
-    if isinstance(task_config, (list, dict)):
+    if not isinstance(task_config, Container):
         task_config = OmegaConf.create(task_config)
     if isinstance(prints, str):
         prints = [prints]
diff --git a/tests/test_hydra.py b/tests/test_hydra.py
--- a/tests/test_hydra.py
+++ b/tests/test_hydra.py
@@ -727,7 +727,7 @@ def test_local_run_workdir(
     )
 
 
-def test_hydra_env_set(tmpdir: Path) -> None:
+def test_hydra_env_set_with_config(tmpdir: Path) -> None:
     cfg = OmegaConf.create({"hydra": {"job": {"env_set": {"foo": "bar"}}}})
     integration_test(
         tmpdir=tmpdir,
@@ -738,6 +738,16 @@ def test_hydra_env_set(tmpdir: Path) -> None:
     )
 
 
+def test_hydra_env_set_with_override(tmpdir: Path) -> None:
+    integration_test(
+        tmpdir=tmpdir,
+        task_config={},
+        overrides=["+hydra.job.env_set.foo=bar"],
+        prints="os.environ['foo']",
+        expected_outputs="bar",
+    )
+
+
 @pytest.mark.parametrize(  # type: ignore
     "override", [pytest.param("xyz", id="db=xyz"), pytest.param("", id="db=")]
 )