Subversion CLI default text editor on Linux - linux

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:
--editor-cmd command-line option
SVN_EDITOR environment variable
editor-cmd runtime configuration option
VISUAL environment variable
EDITOR environment variable
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:
Not using --editor-cmd option when committing
SVN_EDITOR environment variable not set
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.
VISUAL environment variable not set
EDITOR environment variable not set
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.

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.

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).

Try this:
update-alternatives --display editor

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.

Set this in your .bashrc file.
Don't forget to "source .bashrc" or reopen terminal.
export SVN_EDITOR='vim'

Related

How do you get a launcher for firefox?

I hope that I'm tagging/asking on the correct page. I'm Using Linux Mint 6.0, but it could be OS independent.
So the used command for installing Firefox was
nix-env -iA nixpkgs.firefox-esr
When I type which firefox, I get:
/home/foo/.nix-profile/bin/firefox
So Linux Mint comes with Chrome preinstalled, which has a launcher, e.g. also in the start menu. How do I get that for firefox as well? I didn't find a tool to create such a launcher in Mint and I actually think, that nix should do that for me.
EDIT: I also found this page which seemed helpful and advertised e.g. the KDE Kickoff, but I wasn't able to get that one to run.
I can only speak for Ubuntu launchers, but other distros will have launcher files that will have a similar setup
TLDR, add ~/.nix-profile/share to XDG_DATA_DIRS env variable on login. Add the following to ~/.profile after nix loading commands
export XDG_DATA_DIRS=$HOME/.nix-profile/share:$XDG_DATA_DIRS
Explanation:
Installed packages via nix will have an immutable path in nix/store. ~/.nix-profile/bin/firefox is the derivation your current nix environment is linked to (if you update the firefox package, it'll point to the new one)
This means you can create a launcher file for that executable. Lets see if the firefox-esr derivation comes with a desktop launcher or not:
$ nix-build '<nixpkgs>' -A firefox-esr
This will build the package and give you a derivation path. For my current channel it is /nix/store/3iipcmiykgr4p34fg3rkicdz1bw584gm-firefox-102.2.0esr
If I check inside it, there is a .desktop file which defines Ubuntu launchers:
$ ls /nix/store/3iipcmiykgr4p34fg3rkicdz1bw584gm-firefox-102.2.0esr/share/applications
firefox.desktop
These files will also be available under ~/.nix-profile/share/applications so you can simply add that to XDG_DATA_DIRS env variable before boot
If an application did not have one, you can manually make one and add it under ~/.local/share/applications, then set the executable path to the nix one
So SuperSandro2000 explained in the comments, that firefox from nix ships with a .desktop file already. This can be easily added to the start menu and lies in
/nix/store/...-firefox-XXX.X/share/applications/firefox.desktop
If there is no such file included, the most direct way could be (imho) to just create a simple bash script:
#!/bin/bash
./home/foo/.nix-profile/bin/firefox & #Run Firefox
echo Firefox was started with PID $!
In order to make it runnable, enter chmod +x your_skript_name.sh. Afterwards, ./firefox 2> /dev/null & can be used instead to run it silently in the background.
You can also consider the developer/command line options for firefox (Archive) or this blog article here.
Maybe /usr/bin/menulibre is also the right application, it allows you to create .desktop files. This app can also be found by right-clicking on the start "menu".

WSL-2 `code` command installs vscode instead of using local windows install

I have a local vscode installed for windows.
Afterwards I setup wsl-2 and use it as my shell.
When I tried to open a file with code using the code filename command, it installed vscode anew instead of using the local windows install.
Installing VS Code Server for x64 (054a9295330880ed74ceaedda236253b4f39a335)
Is there a way to point wsl to use the windows install when triggering it via the code command?
I don't specifically mind using either or, but settings/extensions etc. for one are not used by the other.
By checking with Git Bash where the location of code is when triggering it (type -a code) and comparing it to the ubuntu wsl shell, I came to the conclusion, that it is actually the same install that is being triggered, . I will have to check why some extensions do not seem to "carry over" though.
The code that is being triggered is a script, that behaves differently when being triggered from within WSL.
How about an alias?
# Set alias
alias code2='/mnt/c/Users/Username/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code'
# Open a file now
code2 file.txt

ncurses test programs failing with message "Error opening terminal: xterm"

(Note: this is similar to this question, but the answer there does not apply.)
Running under FreeBSD, I have ncurses installed via the usual pkg method for FreeBSD, but because I've seen some odd behaviour with a previously working curses program, I decided to download an ncurses source tarball from the official site and compile it under my home directory.
The compile went fine, but attempting to run any of the included test programs results in:
Error opening terminal: xterm.
The documentation does say:
NOTE: You must have installed the terminfo database, or set the
environment variable $TERMINFO to point to a SVr4-compatible terminfo
database before running the test programs. Not all vendors' terminfo
databases are SVr4-compatible, but most seem to be.
So it looks like the answer is to set TERMINFO, but to what? I don't see any terminfo database under the build directory itself, but I do have a file /usr/local/share/misc/terminfo.db installed as a result of the regular FreeBSD installation.
Nevertheless, setting (csh syntax) setenv TERMINFO /usr/local/share/misc/terminfo.db (or the same omitting the .db extension) doesn't make any difference.
(Note: this shouldn't matter because I haven't so far attempted to install the local build, but when I ran "configure", I used: ./configure --prefix=$HOME so that it would install under my home directory.
By default, ncurses uses (reads/writes) a directory-tree of terminal descriptions. Optionally (and seen in the makefile for the ncurses port), it reads/writes a hashed database file, as well as reads the directory-tree.
The INSTALL file in the ncurses sources goes into some detail about the --with-hashed-db configure option, which you apparently overlooked. The term(5) manual page gives a better overview.

zsh option to generate the recomended options

There is a nice option when setting up zsh on Ubuntu
Populate your ~/.zshrc with the configuration recommended
by the system administrator and exit (you will need to edit
the file by hand, if so desired).
However, on a fresh Arch Linux install the option is missing. Is there a way to have it (or maybe, I am being picky here) ?
This happens when you haven't got a .zshrc and there's a /etc/zsh/recommended.zshrc. If you say yes, it'll just copy that one to .zshrc.
Arch, bare-bones awesomesauce that it is, doesn't bother to ship such a file.

Linux automatically environment variables set?

I installed libffi-3.0.11, because another program needs that. But after the installation the other program (by calling the comand ./configure)don't recognize that libffi is installed. Do I have to set a environment variable? Or are all variables set automatically?
usually there is a LIBPATH, you should try to include the directory where your lib resided into this path. In addition, if you have a default bash
export LIBPATH=/your/libffi/path:$LIBPATH
I highly recommend to put this into a script and load it whenever you login automatically so that you don't need to repeat this step
/home/yourhome/.profile <- make sure you insert it into this file and its loaded automatically
Here is a guide how to do the task:
http://archive.linuxfromscratch.org/lfs-museum/5.1-pre1/LFS-BOOK-5.1-PRE1-HTML/chapter06/glibc.html
The parameter you probably need is the following:
./configure --libexecdir=/usr/lib:
If you have installed the libffi library properly this should completely solve your problem.
It depends, if you install libffi on /usr/local you should probably set the includes dir of the app you want to configure to /usr/local.
For the new app, try ./configure --prefix=/usr/local. To see the options of configure, use ./configure --help. Can you show the example of what is not running ?

Resources