Skip to content

Rails assumes that git's merge.tool is a command on the system #54912

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

Open
benjamineskola opened this issue Apr 12, 2025 · 1 comment · May be fixed by rails/thor#900
Open

Rails assumes that git's merge.tool is a command on the system #54912

benjamineskola opened this issue Apr 12, 2025 · 1 comment · May be fixed by rails/thor#900

Comments

@benjamineskola
Copy link

Steps to reproduce

  • Set the git merge tool, e.g. git config merge.tool vimdiff3.
  • Run rails app:update
  • Select the m (merge) option for one of the files.

Expected behavior

Rails launches a configured or default merge tool

Actual behavior

sh: 1: vimdiff3: not found

Rails attempts to read the merge tool from the git configuration, but misinterprets the configuration.

Specifically, it assumes that the value of git config merge.tool is an executable on the system. However, this isn't the case. In fact, the merge.tool setting either refers to a command built in to git (there's a list in the git-config manpage), or to a mergetool.<tool> block in the git configuration.

By coincidence, some of the tool names are the same as system executables (e.g., vimdiff), but there are also many builtin commands that don't have a matching system command (e.g., vimdiff1, vimdiff2, vimdiff3, which are all different configurations of vimdiff using different sets of parameters). Even when the git tool name matches a system executable, it's not guaranteed that the system executable will work in the same way when called directly, since the git tool name refers to a script under (on my system) /usr/lib/git-core/mergetools (or equivalent path), which might at the least add specific parameters to the command to be called.

If the value of merge.tool is not one of git's builtins then what git would actually run is the value of mergetool.<tool>.cmd. Here merge.tool is just an identifier; e.g., I could set merge.tool to emacs and then mergetool.emacs.cmd to emacs --eval '(some complex lisp stuff)'; trying to run emacs directly would not do anything useful (and again it's not required that this key even match the name of a system command; I could have called that emacsmerge instead).

System configuration

Rails version: 8.0.2

Ruby version: 3.4.2

@moguls753
Copy link

Hey! Since the merge‑tool logic lives in Thor (not Rails core), I’ve opened a PR over in the rails/thor repo to address this exact issue: rails/thor#900

That change makes rails app:update’s “m” option correctly handle built‑in identifiers like vimdiff3 (and any custom mergetool..cmd) by delegating to git mergetool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants