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

shutil.SameFileError shallow-backup.conf #260

Closed
pawamoy opened this issue Mar 29, 2020 · 6 comments
Closed

shutil.SameFileError shallow-backup.conf #260

pawamoy opened this issue Mar 29, 2020 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@pawamoy
Copy link

pawamoy commented Mar 29, 2020

With a fresh install (no ~/.config/shallow-backup.conf, no ~/shallow-backup dir):

##########
# DOTFILES
##########

Directory already exists: /home/pawamoy/shallow-backup/dotfiles
[?] Erase directory and make new back up?:  Yes
 >  Yes
    No

Backing up dotfolders...
Backing up dotfiles...
Process Process-15:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.8/shutil.py", line 241, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/pawamoy/.config/shallow-backup.conf' and '/home/pawamoy/.config/shallow-backup.conf' are the same file
@alichtman
Copy link
Owner

alichtman commented Mar 29, 2020

No ~/.config/shallow-backup.conf

You must have a config file to run this app. This error is saying that shallow-backup tried to run copyfile(/home/pawamoy/.config/shallow-backup.conf,/home/pawamoy/.config/shallow-backup.conf), which should not be possible?

I'm not sure what to make of this bug. I don't really understand how you're getting this error.

Can you post your config?

@pawamoy
Copy link
Author

pawamoy commented Mar 29, 2020

I don't really understand how you're getting this error.

It's very simple, I delete both ~/.config/shallow-backup.conf and ~/shallow-backup then run shallow-backup. Just like after a "fresh install".

It's not a critical-error, shutil just complains that the file is the same when trying to move it. But since the exception is not caught, maybe further processing is not done properly (for this "dotfiles" section of the program at least).

% cat ~/.config/shallow-backup.conf 
{
    "backup_path": "~/shallow-backup",
    "dotfiles": [
        ".bashrc",
        ".bash_profile",
        ".gitconfig",
        ".profile",
        ".pypirc",
        "/home/pawamoy/.config/shallow-backup.conf",
        ".tmux.conf",
        ".vimrc",
        ".zlogin",
        ".zprofile",
        ".zshrc"
    ],
    "dotfolders": [
        ".ssh",
        ".vim"
    ],
    "root-gitignore": [
        "dotfiles/.ssh",
        "dotfiles/.pypirc",
        ".DS_Store"
    ],
    "dotfiles-gitignore": [
        ".ssh",
        ".pypirc",
        ".DS_Store"
    ],
    "config_mapping": {
        "/.config/sublime-text-2": "sublime2",
        "/.config/sublime-text-3": "sublime3",
        "/.config/Code/User/settings.json": "vscode/settings",
        "/.config/Code/User/Snippets": "vscode/Snippets",
        "/.config/Code/User/keybindings.json": "vscode/keybindings",
        "/home/pawamoy/.atom": "atom"
    }
}

This config file is what I obtained after running shallow-backup the first time (the same time I get this error really).

Maybe the problem is that shallow-backup's conf file path is absolute, contrary to the other dotfiles? So when shutil tries to do mv abs_path abs_path it fails?

I also see in config_mapping that some paths begin with /.config, others with /home/pawamoy. Should they be normalized to relative path or something?

Note again that file was generated by shallow-backup itself.

@alichtman
Copy link
Owner

alichtman commented Mar 30, 2020

Maybe the problem is that shallow-backup's conf file path is absolute, contrary to the other dotfiles?

Yes, this seems problematic. You can hotfix this by changing the path style to match the other paths.

Also, the config mappings seem to be wrong, as well. My config mappings look like this:

"config_mapping": {
    "/Users/alichtman/Library/Application Support/Sublime Text 2": "sublime2",
    "/Users/alichtman/Library/Application Support/Sublime Text 3": "sublime3",
    "/Users/alichtman/Library/Application Support/Code/User/settings.json": "vscode/settings",
    "/Users/alichtman/Library/Application Support/Code/User/Snippets": "vscode/Snippets",
    "/Users/alichtman/Library/Application Support/Code/User/keybindings.json": "vscode/keybindings",
    "/Users/alichtman/.atom": "atom",
    "/Users/alichtman/Library/Preferences/com.apple.Terminal.plist": "terminal_plist"
    }

Note again that file was generated by shallow-backup itself.

Yep, something weird is happening here.

I'll dig into this issue further when I have time.

For now, I'll post my working config file for v4.0.4:

{
    "backup_path": "~/shallow-backup",
    "dotfiles": [
        ".ctags",
        ".config/agignore",
        ".config/crontab",
        ".config/fzf-notes",
        ".config/git/config",
        ".config/git/gitignore_global",
        ".config/jrnl/jrnl.yaml",
        ".config/pycodestyle",
        ".config/pylintrc",
        ".config/radare2/radare2rc",
        ".config/shallow-backup.conf",
        ".config/starship.toml",
        ".config/tuir/tuir.cfg",
        ".config/zathura/zathurarc",
        ".ghc/ghci.conf",
        ".pypirc",
        ".zprofile"
    ],
    "dotfolders": [
        ".config/kitty",
        ".config/nvim",
        ".config/ranger",
        ".config/zsh",
        ".tmux",
        ".ssh",
        ".vim"
    ],
    "root-gitignore": [
        ".DS_Store",
        "dotfiles/.config/nvim/.netrwhist",
        "dotfiles/.config/nvim/spell/en.utf-8.add",
        "dotfiles/.config/ranger/plugins/ranger_devicons",
        "dotfiles/.config/zsh/.zcompdump*",
        "dotfiles/.pypirc",
        "dotfiles/.ssh"
    ],
    "dotfiles-gitignore": [
        ".DS_Store",
        ".config/nvim/.netrwhist",
        ".config/nvim/spell/en.utf-8.add",
        ".config/ranger/plugins",
        ".config/zsh/.zcompdump*",
        ".tmux/plugins",
        ".tmux/resurrect",
        ".pypirc",
        ".ssh/*",
        ".vim"
    ],
    "config_mapping": {
        "/Users/alichtman/Library/Application Support/Sublime Text 2": "sublime2",
        "/Users/alichtman/Library/Application Support/Sublime Text 3": "sublime3",
        "/Users/alichtman/Library/Application Support/Code/User/settings.json": "vscode/settings",
        "/Users/alichtman/Library/Application Support/Code/User/Snippets": "vscode/Snippets",
        "/Users/alichtman/Library/Application Support/Code/User/keybindings.json": "vscode/keybindings",
        "/Users/alichtman/.atom": "atom",
        "/Users/alichtman/Library/Preferences/com.apple.Terminal.plist": "terminal_plist"
    }
}

@alichtman alichtman added the bug Something isn't working label Mar 30, 2020
@alichtman alichtman self-assigned this Mar 30, 2020
@pawamoy
Copy link
Author

pawamoy commented Mar 30, 2020

Maybe worth noting: I'm on Linux (ArchLabs).

Also in my generated config file, the wrong config mappings seem to be about apps I don't have (VSCode, Sublime).

Anyway, thanks a lot for the help already 🙂

@alichtman
Copy link
Owner

the wrong config mappings seem to be about apps I don't have (VSCode, Sublime).

These are populated by default, but that section of the code could probably use a refactor / fixup.

I'm on Linux

Shouldn't impact anything. Let me mess around to try to repro this.

@alichtman
Copy link
Owner

Should be fixed in v5.0.0a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants