Repository: easybuilders/easybuild-framework

Issue:
using --include-easyblocks-from-pr together with a local easyconfig file fails
Example:

```
$ ls ABAQUS-2019.eb
ABAQUS-2019.eb

$ eb ABAQUS-2019.eb --installpath /tmp/$USER --include-easyblocks-from-pr 2034
...
ERROR: Can't find path /tmp/eb-d2fKqd/tmpA9Jiv_/easybuilders/ABAQUS-2019.eb
```

Using absolute path to easyconfig instead via `eb $PWD/AABQUS-2019.eb ...` does work...


Discussion:
It seems this is actually not *only* related to `--include-easyblocks-from-pr`...

For instance, if you mix that local file with files from `--from-pr`, you get the same behaviour, but it seems it never came up before (?) because that's a weird scenario

The workaround is either to use the absolute path as @boegel mentioned, or to add the folder where the local easyconfig is to the robot path, e.g. in this case with `-r .`

Now, the reason this happens is that the `extract_file` method, called from `download_repo`, changes the working directory (see also https://github.com/easybuilders/easybuild-framework/issues/2858), and in fact everything that comes after `download_repo` seems to rely on that...


Resolving patch:
diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py
--- a/easybuild/tools/github.py
+++ b/easybuild/tools/github.py
@@ -50,7 +50,7 @@
 from easybuild.framework.easyconfig.parser import EasyConfigParser
 from easybuild.tools.build_log import EasyBuildError, print_msg, print_warning
 from easybuild.tools.config import build_option
-from easybuild.tools.filetools import apply_patch, change_dir, copy_dir, copy_easyblocks, copy_framework_files
+from easybuild.tools.filetools import apply_patch, copy_dir, copy_easyblocks, copy_framework_files
 from easybuild.tools.filetools import det_patched_files, download_file, extract_file
 from easybuild.tools.filetools import get_easyblock_class_name, mkdir, read_file, symlink, which, write_file
 from easybuild.tools.py2vs3 import HTTPError, URLError, ascii_letters, urlopen
@@ -364,7 +364,6 @@ def download_repo(repo=GITHUB_EASYCONFIGS_REPO, branch='master', account=GITHUB_
     _log.debug("%s downloaded to %s, extracting now" % (base_name, path))
 
     base_dir = extract_file(target_path, path, forced=True, change_into_dir=False)
-    change_dir(base_dir)
     extracted_path = os.path.join(base_dir, extracted_dir_name)
 
     # check if extracted_path exists


Test patch:
diff --git a/test/framework/github.py b/test/framework/github.py
--- a/test/framework/github.py
+++ b/test/framework/github.py
@@ -345,6 +345,8 @@ def test_download_repo(self):
             print("Skipping test_download_repo, no GitHub token available?")
             return
 
+        cwd = os.getcwd()
+
         # default: download tarball for master branch of easybuilders/easybuild-easyconfigs repo
         path = gh.download_repo(path=self.test_prefix, github_user=GITHUB_TEST_ACCOUNT)
         repodir = os.path.join(self.test_prefix, 'easybuilders', 'easybuild-easyconfigs-master')
@@ -354,6 +356,9 @@ def test_download_repo(self):
         self.assertTrue(re.match('^[0-9a-f]{40}$', read_file(shafile)))
         self.assertTrue(os.path.exists(os.path.join(repodir, 'easybuild', 'easyconfigs', 'f', 'foss', 'foss-2019b.eb')))
 
+        # current directory should not have changed after calling download_repo
+        self.assertTrue(os.path.samefile(cwd, os.getcwd()))
+
         # existing downloaded repo is not reperformed, except if SHA is different
         account, repo, branch = 'boegel', 'easybuild-easyblocks', 'develop'
         repodir = os.path.join(self.test_prefix, account, '%s-%s' % (repo, branch))