Skip to content

Commit

Permalink
Fixed a "PermissionError: [WinError 5]" on Windows when external repo…
Browse files Browse the repository at this point in the history
…sitory is used with `lib_deps` option // Resolve #3664
  • Loading branch information
ivankravets committed Sep 12, 2020
1 parent 7bc170a commit 687c339
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ PlatformIO Core 5
5.0.2 (2020-09-??)
~~~~~~~~~~~~~~~~~~

- Fixed an issue with "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)
- Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with `lib_deps <https://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option (`issue #3664 <https://github.com/platformio/platformio-core/issues/3664>`_)
- Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)

5.0.1 (2020-09-10)
~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 8 additions & 5 deletions platformio/package/manager/_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def install_from_url(self, url, spec, checksum=None, silent=False):
return self._install_tmp_pkg(pkg_item)
finally:
if os.path.isdir(tmp_dir):
fs.rmtree(tmp_dir)
try:
shutil.rmtree(tmp_dir)
except: # pylint: disable=bare-except
pass

def _install_tmp_pkg(self, tmp_pkg):
assert isinstance(tmp_pkg, PackageItem)
Expand Down Expand Up @@ -213,10 +216,10 @@ def _cleanup_dir(path):
# move existing into the new place
pkg_dir = os.path.join(self.package_dir, target_dirname)
_cleanup_dir(pkg_dir)
shutil.move(dst_pkg.path, pkg_dir)
shutil.copytree(dst_pkg.path, pkg_dir, symlinks=True)
# move new source to the destination location
_cleanup_dir(dst_pkg.path)
shutil.move(tmp_pkg.path, dst_pkg.path)
shutil.copytree(tmp_pkg.path, dst_pkg.path, symlinks=True)
return PackageItem(dst_pkg.path)

if action == "detach-new":
Expand All @@ -233,10 +236,10 @@ def _cleanup_dir(path):
)
pkg_dir = os.path.join(self.package_dir, target_dirname)
_cleanup_dir(pkg_dir)
shutil.move(tmp_pkg.path, pkg_dir)
shutil.copytree(tmp_pkg.path, pkg_dir, symlinks=True)
return PackageItem(pkg_dir)

# otherwise, overwrite existing
_cleanup_dir(dst_pkg.path)
shutil.move(tmp_pkg.path, dst_pkg.path)
shutil.copytree(tmp_pkg.path, dst_pkg.path, symlinks=True)
return PackageItem(dst_pkg.path)

0 comments on commit 687c339

Please sign in to comment.