msanders / cider

Hassle-free bootstrapping with Homebrew.
https://pypi.python.org/pypi/cider/
MIT License
839 stars 25 forks source link

Symlinking Crashing - RuntimeError: dictionary changed size during iteration #49

Closed kishansairam9 closed 5 years ago

kishansairam9 commented 5 years ago

Following Runtime Error is encountered on trying unlink

~
❯ cider addlink iterm2profiles .iterm2profiles
Success! symlinked ~/.iterm2profiles -> ~/.cider/symlinks/iterm2profiles/.iterm2profiles

~
❯ cider unlink iterm2profiles
==> Moved ~/.cider/symlinks/iterm2profiles/.iterm2profiles -> ~/.iterm2profiles
Traceback (most recent call last):
  File "/usr/local/bin/cider", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/cider/_cli.py", line 251, in main
    cli.main(standalone_mode=False)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 26, in new_func
    return ctx.invoke(f, ctx.obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/cider/_cli.py", line 246, in unlink
    cider.unlink(name)
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 661, in unlink
    self.remove_symlink(name)
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 604, in remove_symlink
    return self._modify_bootstrap("symlinks", transform)
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 116, in _modify_bootstrap
    return modify_config(self.bootstrap_file, outer_transform)
  File "/usr/local/lib/python3.7/site-packages/cider/_sh.py", line 214, in modify_config
    contents = transform(copy.deepcopy(contents))
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 110, in outer_transform
    bootstrap[key] = transform(bootstrap.get(key, fallback))
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 598, in transform
    for key in symlinks.keys():
RuntimeError: dictionary changed size during iteration

~
❯ cider unlink iterm2profiles
Traceback (most recent call last):
  File "/usr/local/bin/cider", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/cider/_cli.py", line 251, in main
    cli.main(standalone_mode=False)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 26, in new_func
    return ctx.invoke(f, ctx.obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/cider/_cli.py", line 246, in unlink
    cider.unlink(name)
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 659, in unlink
    raise e
  File "/usr/local/lib/python3.7/site-packages/cider/core.py", line 656, in unlink
    os.rmdir(os.path.join(self.symlink_dir, name))
FileNotFoundError: [Errno 2] No such file or directory: '/Users/kishansairam9/.cider/symlinks/iterm2profiles'

Aftermath:

kishansairam9 commented 5 years ago

Fix: https://github.com/kishansairam9/cider/commit/5102a8d0046ece5eaa78490ff766f9a1c23661f6

After Fix:

~/Repos
❯ cider addlink test2 test2
Success! symlinked ~/Repos/test2 -> ~/.cider/symlinks/test2/test2

~/Repos
❯ cider unlink test2
==> Moved ~/.cider/symlinks/test2/test2 -> ~/Repos/test2