Repository: conan-io/conan

Issue:
[bug] Conan build command does not support conanfile.txt as described
### Description

The documentation about [build](https://docs.conan.io/2/reference/commands/build.html) command says:

```
usage: conan build [-h] [-v [V]] [--logger] [--name NAME] [--version VERSION] [--user USER] [--channel CHANNEL] [-of OUTPUT_FOLDER] [-b BUILD] [-r REMOTE | -nr] [-u] [-o OPTIONS_HOST] [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST] [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD]
                   [-pr:h PROFILE_HOST] [-s SETTINGS_HOST] [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST] [-c CONF_HOST] [-c:b CONF_BUILD] [-c:h CONF_HOST] [-l LOCKFILE] [--lockfile-partial] [--lockfile-out LOCKFILE_OUT] [--lockfile-packages] [--lockfile-clean]
                   [path]

Install dependencies and call the build() method.

positional arguments:
  path                  Path to a folder containing a recipe (conanfile.py or conanfile.txt) or to a recipe file. e.g., ./my_project/conanfile.txt.
```

However, `conanfile.txt` is not acceptable by build command.

As the documentation is extracted from the command output, it should be fixed on Conan client first.


### Environment details

* Operating System+version: OSX 13
* Compiler+version: Apple-Clang 14
* Conan version: 2.0.0
* Python version: 3.10


### Steps to reproduce

1. mkdir /tmp/foo && cd /tmp/foo
2. echo "[requires]\nzlib/1.2.13" > conanfile.txt
3. conan build .
4. Or, conan build ./conanfile.txt

### Logs

```
% conan build .
ERROR: Conanfile not found at /private/tmp/foo/conanfile.py

% conan build ./conanfile.txt   
ERROR: A conanfile.py is needed, /private/tmp/conantxt/conanfile.txt is not acceptable
```

Discussion:
CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/conan-io/conan?pullRequest=13211) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/conan-io/conan?pullRequest=13211) before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/conan-io/conan?pullRequest=13211) it.</sub>

Patch:
diff --git a/conan/cli/commands/build.py b/conan/cli/commands/build.py
index 4d756c82d..2a4f0be57 100644
--- a/conan/cli/commands/build.py
+++ b/conan/cli/commands/build.py
@@ -15,9 +15,9 @@ def build(conan_api, parser, *args):
     Install dependencies and call the build() method.
     """
     parser.add_argument("path", nargs="?",
-                        help="Path to a folder containing a recipe (conanfile.py "
-                             "or conanfile.txt) or to a recipe file. e.g., "
-                             "./my_project/conanfile.txt.")
+                        help='Path to a python-based recipe file or a folder '
+                             'containing a conanfile.py recipe. conanfile.txt '
+                             'cannot be used with conan build.')
     add_reference_args(parser)
     # TODO: Missing --build-require argument and management
     parser.add_argument("-of", "--output-folder",
diff --git a/conans/model/options.py b/conans/model/options.py
index 7a7912c8a..c7b879c8f 100644
--- a/conans/model/options.py
+++ b/conans/model/options.py
@@ -338,7 +338,10 @@ class Options:
         result = Options()
         result._package_options = self._package_options.copy_conaninfo_options()
         # In most scenarios this should be empty at this stage, because it was cleared
-        assert not self._deps_package_options
+        if self._deps_package_options:
+            raise ConanException("Dependencies options were defined incorrectly. Maybe you"
+                                 " tried to define options values in 'requirements()' or other"
+                                 " invalid place")
         return result
 
     def update(self, options=None, options_values=None):


Test patch:
diff --git a/conans/test/integration/conanfile/conanfile_errors_test.py b/conans/test/integration/conanfile/conanfile_errors_test.py
index 9951494b8..057bde53f 100644
--- a/conans/test/integration/conanfile/conanfile_errors_test.py
+++ b/conans/test/integration/conanfile/conanfile_errors_test.py
@@ -175,3 +175,20 @@ def test_notduplicate_requires_py():
     client.save(files)
     client.run("export .")
     assert "hello/0.1: Exported" in client.out
+
+
+def test_requirements_change_options():
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+
+        class HelloConan(ConanFile):
+            name = "hello"
+            version = "0.1"
+
+            def requirements(self):
+                self.options["mydep"].myoption = 3
+        """)
+    c.save({"conanfile.py": conanfile})
+    c.run("create .", assert_error=True)
+    assert "Dependencies options were defined incorrectly." in c.out