Sheila Markazi
Sheila Markazi

Reputation: 21

After git merge workingbranch, how to remove the error "error: cannot run sublime: No such file or directory"

I'm using git on my terminal trying to merge the changes from my working branch to the master. I use the merge command and get an error that says "cannot run sublime:No such file or directory." and "unable to start editor 'sublime'."

I do not have sublime on my computer and do not want to use it. I would just like to get rid of these errors.

I continued on by adding, committing, and pushing the changes, and I saw that everything is now successfully showing up in Github. So it looks like the merge command successfully let me integrate my changes from the working branch to the master.

I checked my computer by searching for "sublime" in Launchpad and Finder, and I do not have the Sublime editor. I vaguely remember installing it once to try it out. But I seem to have uninstalled it.

Sheilas-MBP:violinportfolio Sheila$ git merge working --no-ff

error: cannot run sublime: No such file or directory

error: unable to start editor 'sublime'

Not committing merge; use 'git commit' to complete the merge.

Upvotes: 2

Views: 671

Answers (1)

torek
torek

Reputation: 487755

Either your system Git is configured to use sublime as the system-default editor (which seems unlikely), or you configured Git to use sublime as your default editor (which seems pretty likely).

The one bit of trouble here is finding out how you configured this, because there are a lot of ways to configure it. The most common method is to use the core.editor setting:

git config --get core.editor

may print sublime, in which case you can use git config again to un-set that, and/or to choose whatever editor you do prefer.

In general, if you're setting your core.editor preference, you would want to use git config --global, as this sets your personal default for all Git repositories. So if you want to use, say, vim, you would run:

git config --global core.editor vim

Presumably, you did this earlier to set it to sublime. However, it's possible that you did instead:

git config core.editor sublime

earlier. If so, that set sublime as your preferred editor for this particular Git repository only, and that setting will continue to override any global setting. In that case, you'll need to un-set the local setting:

git config --unset core.editor

Should you wish to unset your global setting, you can use:

git config --global --unset core.editor

These are not the only places where you can set your preferred editor, but these are the most likely settings. The other possibilities are environment variables: $GIT_EDITOR, $VISUAL, and $EDITOR.

Summary

  • There are system (all users of this computer), global (all of your repositories on this computer), and local (this repository right now) settings for Git variables. In the latest version of Git there are even per-work-tree settings that apply if you use git worktree add. Use:

    git config --show-origin --list
    

    to see all settings and where they are set.

  • The editor to use is chosen from the first one of these that is set:

    • $GIT_EDITOR (in the environment)
    • core.editor (from all Git configurations)
    • $VISUAL (in the environment)
    • $EDITOR (in the environment)
    • the compiled-in default (from your Git installation)


    These are the places to inspect for settings, if core.editor is not controlling which editor you use.

Upvotes: 2

Related Questions