Emacs Snapshot step: "cp: ~/.emacs.d/elpa: No such file or directory"
Erroneous Behavior
I switched from Elpaca to the built-in Emacs package manager last month, trying to reduce the number of possible points of failure (and the complexity of my configuration). Today I thought that I might want to re-enable the Emacs step in Topgrade as well. (I had it disabled while I didn't use package.el.)
However, it won't work too well.
; topgrade
── 18:16:48 - Emacs Snapshot ───────────────────────────────────────────────────
cp: ~/.emacs.d/elpa: No such file or directory
Error:
0: Command failed: `/Users/tux0r/.local/bin/rc -c 'rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak'`
1: `/Users/tux0r/.local/bin/rc` failed: exit status: 1
Location:
src/steps/generic.rs:703
It looks like Topgrade can't properly resolve ~ on some shells, because I am absolutely sure that /Users/tux0r/.emacs.d/elpa exists (and is not a hard link).
Expected Behavior
Well, it shouldn't break.
Steps to reproduce
Just use Topgrade's built-in Emacs updater.
Problem persists without calling from topgrade
- [x] Yes
- [ ] No
Maybe it would make sense to use $HOME instead?
Did you run topgrade through Remote Execution
- [ ] Yes
- [x] No
If yes, does the issue still occur when you run topgrade directlly in your remote host
- [ ] Yes
- [ ] No
Additional Details
-
Operation System/Version macOS Sonoma
-
Installation via Homebrew
-
Topgrade version (
topgrade -V) Topgrade 15.0.0
Verbose Output (topgrade -v)
DEBUG Configuration at /Users/tux0r/.config/topgrade.toml
DEBUG Loaded configuration: ConfigFile { include: None, misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: Some([Stack, Gem, RubyGems]), ignore_failures: Some([Containers]), remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, cleanup: Some(true), notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({"Emacs Snapshot": "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"}), post_commands: None, commands: Some({"GitUp": "cd /Users/tux0r && ./gitup.sh"}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: Some(true), pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: Some(true), greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: None, vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: None }
DEBUG Version: 15.0.0
DEBUG OS: aarch64-apple-darwin
DEBUG Args { inner: ["topgrade", "-v"] }
DEBUG Binary path: Ok("/opt/homebrew/bin/topgrade")
DEBUG self-update Feature Enabled: false
DEBUG Configuration: Config { opt: CommandLineArgs { edit_config: false, show_config_reference: false, run_in_tmux: false, cleanup: false, dry_run: false, no_retry: false, disable: [], only: [], custom_commands: [], env: [], verbose: true, keep_at_end: false, skip_notify: false, yes: None, disable_predefined_git_repos: false, config: None, remote_host_limit: None, show_skipped: false, log_filter: "warn", gen_completion: None, gen_manpage: false, no_self_update: false }, config_file: ConfigFile { include: None, misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: Some([Stack, Gem, RubyGems]), ignore_failures: Some([Containers]), remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, cleanup: Some(true), notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({"Emacs Snapshot": "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"}), post_commands: None, commands: Some({"GitUp": "cd /Users/tux0r && ./gitup.sh"}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: Some(true), pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: Some(true), greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: None, vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: None }, allowed_steps: [AM, AppMan, Asdf, Atom, Audit, AutoCpufreq, Bin, Bob, BrewCask, BrewFormula, Bun, BunPackages, Cargo, Certbot, Chezmoi, Chocolatey, Choosenim, ClamAvDb, Composer, Conda, ConfigUpdate, Containers, CustomCommands, DebGet, Deno, Distrobox, DkpPacman, Dotnet, Elan, Emacs, Firmware, Flatpak, Flutter, Fossil, Gcloud, Ghcup, GithubCliExtensions, GitRepos, GnomeShellExtensions, Go, Guix, Haxelib, Helm, HomeManager, Jetpack, Julia, Juliaup, Kakoune, Helix, Krew, Lure, Lensfun, Macports, Mamba, Miktex, Mas, Maza, Micro, Mise, Myrepos, Nix, Node, Opam, Pacdef, Pacstall, Pearl, Pip3, PipReview, PipReviewLocal, Pipupgrade, Pipx, Pkg, Pkgin, PlatformioCore, Pnpm, Powershell, Protonup, Pyenv, Raco, Rcm, Remotes, Restarts, Rtcl, Rustup, Rye, Scoop, Sdkman, SelfUpdate, Sheldon, Shell, Snap, Sparkle, Spicetify, Stew, System, Tldr, Tlmgr, Tmux, Toolbx, Vagrant, Vcpkg, Vim, Vscode, Waydroid, Winget, Wsl, WslUpdate, Xcodes, Yadm, Yarn] }
DEBUG Cannot find "pwsh"
DEBUG Cannot find "powershell"
DEBUG Path "/Users/tux0r/.config/emacs" doesn't exist
DEBUG Path "/Users/tux0r/.emacs.d" exists
DEBUG Path "/Users/tux0r/.emacs.d/bin/doom" doesn't exist
DEBUG Cannot find "doas"
DEBUG Detected "/usr/bin/sudo" as "sudo"
── 18:30:55 - Emacs Snapshot ───────────────────────────────────────────────────
DEBUG Executing command /Users/tux0r/.local/bin/rc -c 'rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak'
cp: ~/.emacs.d/elpa: No such file or directory
DEBUG Command failed: Err(
0: Command failed: /Users/tux0r/.local/bin/rc -c 'rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak'
1: /Users/tux0r/.local/bin/rc failed: exit status: 1
Location:
src/steps/generic.rs:703)
Error:
0: Command failed: /Users/tux0r/.local/bin/rc -c 'rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak'
1: /Users/tux0r/.local/bin/rc failed: exit status: 1
Location:
src/steps/generic.rs:703
The step seems to be a custom step, i.e., not a built-in step supported by Topgrade, right?
Topgrade can't properly resolve ~ on some shells,
If this is a custom step, then Topgrade does not resolve the ~ sign itself, it passes it to the shell.
/Users/tux0r/.local/bin/rc
Looks like you are using a shell called rc, does this issue exist if you change the shell to something else, e.g., the default zsh?
The step seems to be a custom step, i.e., not a built-in step supported by Topgrade, right?
Depends. All I did was uncomment a line in the supported ;-) default configuration: https://github.com/topgrade-rs/topgrade/blob/main/config.example.toml#L80
Yes, the rc shell does not "auto-expand" the ~, so my suggestion to use $HOME instead could also avoid further issues, I guess?
Yes, the rc shell does not "auto-expand" the
~
Interesting, this is the first shell that I know that doesn't expand the ~ sign 🤔
Depends. All I did was uncomment a line in the supported ;-) default configuration:
Yeah, that is a custom pre-command, you can write any shell script there that can be interrupted by your shell.
So my suggestion to use $HOME instead could also avoid further issues, I guess?
The current script would work for most shells, you can edit the command in your configuration file to expand the ~ yourself. ;)
Since this is a custom command, this is not an issue in Topgrade.
Since rc is not a widely-used shell (sorry), I do not see the need to modify the example pre_command.
If the rc shell causes other issues that are not caused by custom commands (like Topgrade itself using ~ somewhere), please open a new issue!