Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

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

Closed
kishansairam9 opened this issue Jul 5, 2019 · 1 comment

Comments

@kishansairam9
Copy link
Contributor

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:

  • Symlinked files restored to original state before addlink is executed sucessfully 👍
  • Symlinked files delted from .cider 👍 (This is causing FileNotFoundError when running unlink again after getting RuntimeError)
  • Description of symlink is left in bootstrap.json ⚠️
@kishansairam9
Copy link
Contributor Author

Fix: kishansairam9@5102a8d

  • Instead of deleting key directly from symlinks in remove_symlinks function, create list containing keys to delete
  • Iterate over created list and delete the keys from symlinks so that its size is constant throughout the iteration

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

msanders added a commit that referenced this issue Jul 7, 2019
Fix #47: Deprecation Warning, #50: Attribute Error, #49: Runtime Error
kishansairam9 added a commit to kishansairam9/cider that referenced this issue Jul 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant