Repository: conan-io/conan

Issue:
[REGRESSION] `conan info` does not work correctly with 1.17.0
After upgrading Conan from `1.16.1` to `1.17.0`, `conan info` command stopped working.

Here is the output for one package with Conan v1.16.1:

```
$ conan info AndroidNdk/r20@microblink/stable
AndroidNdk/r20@microblink/stable
    ID: 743cf0321be3152777da4d05247a66d1552e70a2
    BuildID: None
    Remote: microblink=http://artifactory.microblink.com/artifactory/api/conan/conan-local
    URL: https://developer.android.com/ndk/downloads/
    Recipe: Cache
    Binary: Cache
    Binary remote: microblink
    Creation date: 2019-06-18 11:00:55
```

The same command with Conan `v1.17.0` gives the following:

```
conan info AndroidNdk/r20@microblink/stable
ERROR: AndroidNdk/r20@microblink/stable: 'options.enable_testing' doesn't exist
Possible options are []
```

I haven't given any option to `conan info`, so where does it get it from? Furthermore, if same command is given from empty folder, then it works. My guess is that it is somehow related to executing this command from folder that contains `conan.lock` for completely different package (which does have `enable_testing` option).

Now, why does `conan info` read lockfile even if `--lockfile` option is not given.

I've tried removing the `conan.lock` file, and then something even weirder happens:

```
$ rm conan.lock
[dodo@knight-rider: Debug]$ conan info AndroidNdk/r20@microblink/stable
ERROR: Missing lockfile in: /my/current/folder/containing/cmake/cache/and/conan/installation/for/different/package
```

However, deleting file `graph_info.json` from current folder makes `conan info` work, however I do not want to do that - I am not interested for information about conan package installed in current folder (if I were, I would call `conan info /path/to/conanfile.py`).


Discussion:
Reproduced

Resolving patch:
diff --git a/conans/client/conan_api.py b/conans/client/conan_api.py
--- a/conans/client/conan_api.py
+++ b/conans/client/conan_api.py
@@ -621,12 +621,13 @@ def _info_args(self, reference_or_path, install_folder, profile_names, settings,
         cwd = get_cwd()
         try:
             ref = ConanFileReference.loads(reference_or_path)
+            install_folder = _make_abs_path(install_folder, cwd) if install_folder else None
         except ConanException:
             ref = _get_conanfile_path(reference_or_path, cwd=None, py=None)
 
-        install_folder = _make_abs_path(install_folder, cwd)
-        if not os.path.exists(os.path.join(install_folder, GRAPH_INFO_FILE)):
-            install_folder = None
+            install_folder = _make_abs_path(install_folder, cwd)
+            if not os.path.exists(os.path.join(install_folder, GRAPH_INFO_FILE)):
+                install_folder = None
 
         lockfile = _make_abs_path(lockfile, cwd) if lockfile else None
         graph_info = get_graph_info(profile_names, settings, options, env, cwd, install_folder,


Test patch:
diff --git a/conans/test/functional/command/info_test.py b/conans/test/functional/command/info_test.py
--- a/conans/test/functional/command/info_test.py
+++ b/conans/test/functional/command/info_test.py
@@ -630,3 +630,16 @@ def wrong_graph_info_test(self):
         save(path, "broken thing")
         client.run("info .", assert_error=True)
         self.assertIn("ERROR: Error parsing GraphInfo from file", client.out)
+
+    def previous_lockfile_error_test(self):
+        # https://github.com/conan-io/conan/issues/5479
+        client = TestClient()
+        client.save({"conanfile.py": TestConanFile("pkg", "0.1")})
+        client.run("create . user/testing")
+        client.save({"conanfile.py": TestConanFile("other", "0.1",
+                                                   options="{'shared': [True, False]}",
+                                                   default_options='shared=False')})
+        client.run("install . -o shared=True")
+        client.run("info pkg/0.1@user/testing")
+        self.assertIn("pkg/0.1@user/testing", client.out)
+        self.assertNotIn("shared", client.out)