Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing sources error message #6085

Merged
merged 1 commit into from Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions conans/client/source.py
Expand Up @@ -19,7 +19,8 @@ def complete_recipe_sources(remote_manager, cache, conanfile, ref, remotes):
occassions, conan needs to get them too, like if uploading to a server, to keep the recipes
complete
"""
sources_folder = cache.package_layout(ref, conanfile.short_paths).export_sources()
package_layout = cache.package_layout(ref, conanfile.short_paths)
sources_folder = package_layout.export_sources()
if os.path.exists(sources_folder):
return None

Expand All @@ -29,15 +30,23 @@ def complete_recipe_sources(remote_manager, cache, conanfile, ref, remotes):

# If not path to sources exists, we have a problem, at least an empty folder
# should be there
current_remote = cache.package_layout(ref).load_metadata().recipe.remote
current_remote = package_layout.load_metadata().recipe.remote
if current_remote:
current_remote = remotes[current_remote]
if not current_remote:
raise ConanException("Error while trying to get recipe sources for %s. "
"No remote defined" % str(ref))
msg = ("The '%s' package has 'exports_sources' but sources not found in local cache.\n"
"Probably it was installed from a remote that is no longer available.\n"
% str(ref))
raise ConanException(msg)

export_path = cache.package_layout(ref).export()
remote_manager.get_recipe_sources(ref, export_path, sources_folder, current_remote)
export_path = package_layout.export()
try:
remote_manager.get_recipe_sources(ref, export_path, sources_folder, current_remote)
except Exception as e:
msg = ("The '%s' package has 'exports_sources' but sources not found in local cache.\n"
"Probably it was installed from a remote that is no longer available.\n"
% str(ref))
raise ConanException("\n".join([str(e), msg]))


def config_source_local(src_folder, conanfile, conanfile_path, hook_manager):
Expand Down
19 changes: 0 additions & 19 deletions conans/test/functional/conan_api/config.py

This file was deleted.

19 changes: 19 additions & 0 deletions conans/test/functional/conan_api/config_test.py
@@ -0,0 +1,19 @@
import unittest

from conans.client import conan_api


class ConfigTest(unittest.TestCase):

def setUp(self):
self.api, _, _ = conan_api.ConanAPIV1.factory()

def config_rm_test(self):
self.api.config_set("proxies.https", "http://10.10.1.10:1080")
self.assertIn("proxies", self.api.app.config.sections())
self.api.config_rm('proxies')
self.assertNotIn("proxies", self.api.app.config.sections())

def test_config_home(self):
conan_home = self.api.config_home()
self.assertEqual(self.api.cache_folder, conan_home)
39 changes: 39 additions & 0 deletions conans/test/functional/remote/multi_remote_test.py
@@ -1,3 +1,4 @@
import textwrap
import time
import unittest
from collections import OrderedDict
Expand All @@ -9,6 +10,44 @@
from conans.test.utils.tools import TestClient, TestServer


class ExportsSourcesMissingTest(unittest.TestCase):

def exports_sources_missing_test(self):
client = TestClient(default_server_user=True)
conanfile = textwrap.dedent("""
from conans import ConanFile
class Pkg(ConanFile):
exports_sources = "*"
""")
client.save({"conanfile.py": conanfile,
"source.txt": "somesource"})
client.run("create . pkg/0.1@user/testing")
client.run("upload pkg/0.1@user/testing --all")

# Failure because remote is removed
servers = OrderedDict(client.servers)
servers["new_server"] = TestServer(users={"user": "password"})
client2 = TestClient(servers=servers, users={"new_server": [("user", "password")]})
client2.run("install pkg/0.1@user/testing")
client2.run("remote remove default")
client2.run("upload pkg/0.1@user/testing --all -r=new_server", assert_error=True)
self.assertIn("The 'pkg/0.1@user/testing' package has 'exports_sources' but sources "
"not found in local cache.", client2.out)
self.assertIn("Probably it was installed from a remote that is no longer available.",
client2.out)

# Failure because remote is disconnected
client2 = TestClient(servers=servers, users={"new_server": [("user", "password")]})
client2.run("install pkg/0.1@user/testing")
client2.run("remote add default http://someweird__conan_URL -f")
client2.run("upload pkg/0.1@user/testing --all -r=new_server", assert_error=True)
self.assertIn("Unable to connect to default=http://someweird__conan_URL", client2.out)
self.assertIn("The 'pkg/0.1@user/testing' package has 'exports_sources' but sources "
"not found in local cache.", client2.out)
self.assertIn("Probably it was installed from a remote that is no longer available.",
client2.out)


class MultiRemotesTest(unittest.TestCase):

def setUp(self):
Expand Down