3

While there is no shortage of information on how to set a text editor for the Subversion Command Line Interface to use (see here, here, and here for example), I can't figure out where my local system is getting the text editor information from.

On my system, when I perform an svn commit, it opens vim for a commit message. Since this is what I want, I never really thought about it. This has always just worked. However, recently a co-worker was trying to commit, and it failed with an error saying the editor was not set. I never went out of my way to set an editor, so I am very confused about this.

I am running Ubuntu 12.04 and I have compiled and installed the Subversion CLI client version 1.8.10 from source code. Previous to that, I was using whatever Ubuntu's Canonical system installed with apt-get install subversion.

The Using External Editors section of the Subversion Book states the following possibilities for setting the text editor:

  1. --editor-cmd command-line option
  2. SVN_EDITOR environment variable
  3. editor-cmd runtime configuration option
  4. VISUAL environment variable
  5. EDITOR environment variable
  6. Possibly, a fallback value built into the Subversion libraries (not present in the official builds)

I have investigated these places and have not found how the default text editor is set on my computer:

  1. Not using --editor-cmd option when committing
  2. SVN_EDITOR environment variable not set
  3. editor-cmd is not set in either my ~/.subversion/config, nor in /etc/subversion/config. Both of these files exist, but the line is commented out.
  4. VISUAL environment variable not set
  5. EDITOR environment variable not set
  6. I'm downloading the official repository, so there should be no fallback.

There must be another place where the default can be set. Does anybody know?

Edit: There was a suggestion that Subversion might be calling /usr/bin/editor, and this is not set up on my co-worker's machine. I discovered that /usr/bin/editor is set up the same on both my system and my co-worker's system.

4
  • 2
    Use ltrace on your svn command to find out. Perhaps the svn binary has something built-in; try strings $(which svn) Commented Oct 22, 2014 at 17:40
  • Did you confirm that the version of subversion you were using was the one you built? Is it possible you have both installed and are running the wrong one? I'd verify by running svn --version Commented Oct 29, 2014 at 0:04
  • Calling svn --version on both machines reveals that they are both running Subversion version 1.8.10. Commented Oct 29, 2014 at 0:23
  • Can you tell me what command line you used to configure your subversion build (You must have got the sources and done a ./configure; make; sudo make install or something similar). What I am curious about is whether you specified any options for ./configure. If you didn't use ./configure how did you build from source? Commented Oct 29, 2014 at 0:37

4 Answers 4

3
+50

When you download the source directly (and build it - assuming you have the build dependencies met) you specify (or you can omit it) the default fallback editor. Normally source builds are done with something like this on Ubuntu (assume I have extracted/downloaded the subversion 1.8.10 source from here):

./configure
make
sudo make install

Notice the ./configure command above doesn't specify any options. The defaults will install to the prefix /usr/local . Prior to issuing those commands (on Ubuntu 12.04) I ran sudo apt-get build-dep subversion . I then did the commands above to build and install. I made sure that options 1-5 (In the OPs question) were not satisfied and then tried to commit a change to a repository. I got this as a response:

svn: E205007: Commit failed (details follow):
svn: E205007: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
svn: E205007: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found

Since I didn't remove the official Ubuntu subversion I had to run mine as /usr/local/bin/svn to make sure I was using the one I built. I could have used sudo apt-get remove subversion to remove the official one as well just to make sure.

Now if one runs these commands to rebuild the source:

make clean
./configure --with-editor=/usr/bin/editor
make
sudo make install

One should find that if options 1 to 5 are not satisfied and this version of subversion is run it should default to running whatever /usr/bin/editor points to. On Ubuntu that will depend on what alternative is being used.

So when Ubuntu does an official build where does their fallback editor come from? I went to the 12.04 source repository for subversion at this link . On the right hand side I downloaded the diff file subversion_1.6.17dfsg-3ubuntu3.4.diff.gz . I opened up the diff file Ubuntu uses and scrolling down you can find they use this set of ./configure options (flags):

confflags := \ --prefix=/usr \ --libdir=$(libdir) \ --mandir=\$${prefix}/share/man \ --with-apr=/usr \ --with-apr-util=/usr \ --with-neon=/usr \ --with-serf=/usr \ --with-berkeley-db=:::db \ --with-sasl=/usr \ --with-editor=/usr/bin/editor \ --with-ruby-sitedir=/usr/lib/ruby \ --with-swig=/usr \ --with-kwallet \ --with-gnome-keyring

The bold entry shows that they use /usr/bin/editor as their fallback.

I have built subversion 1.8.10 from source on Ubuntu 12.04 and got the expected behavior. This suggests one of these possibilities:

  • On one of the systems the options 1 through 5 is actually met.
  • One version of subversion was built with the --with-editor configure flag (either directly or indirectly). The fallback would point to whatever the --with-editor configure flag was set to.
  • On one of the systems the wrong version of subversion is being run. One possibility is that the official subversion on Ubuntu is in fact being used. If that is the case it was built to use /usr/bin/editor as a fallback.
  • On one of your systems you have an alias (or equivalent) for svn that specifies an editor. Aliases would be specified in a startup script like ~/.bashrc, ~/.bash_profile, /etc/bash.bashrc for example.
Sign up to request clarification or add additional context in comments.

Comments

0

I think the normal way to specify this on Linux and other Unix-like systems, is to set the VISUAL environment variable (for GUI editors) or the EDITOR variable (for editors running in a terminal).

1 Comment

As stated in my question, none of the environment variables are set on my system, yet it works (i.e. brings up vim on commit)
0

Try this:

update-alternatives --display editor

6 Comments

It looks like you're talking about the "alternatives" system which I'd actually not heard about until just now. linux.die.net/man/8/alternatives gives some information about the system and its capabilities, I'm not sure if there's a better resource.
I do not have update-alternatives on my system. Please update your answer with information on what you think this has to do with my issue. How does this system tie into Subversion, assuming it does at all?
The alternatives system is standard for Debian derivatives, as far as I know. You mentioned you were using an Ubuntu machine. Debian derivatives use dpkg for installing, uninstalling and purging applications, right? (synaptic etc. are front-ends). /usr/bin/update-alternatives is installed by the dpkg package. With the command I gave you you would find out to which editor /usr/bin/editor links to. Is it vim?
I just now checked, and this is set up the same on both my computer and my co-worker's computer. /usr/bin/editor links to /etc/alternatives/editor links to /usr/bin/vim.gnome. So it would appear that Subversion does not call /usr/bin/editor by default.
Are you both using the same version of subversion and was it compiled the same way? svn --version; md5sum $(which svn)
|
0

Run strings on your svn binary to see if it mentions Vim or any related env vars inside.

Also committing under strace -f may reveal something.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.