2

I need to use sudo to run svn commands on my project. I have the SVN_EDITOR set to be vi in my own .bash_profile as well as in the root user's .bash_profile, but when I try to do an svn propedit, I get

svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found

Each time I start a new session, I have to set the SVN_EDITOR. This is a pain. Any suggestions on how/where I can set SVN_EDITOR permanently? This is on CentOS 5.4.

3
  • 1
    Look for the env_check and env_keep optionss in sudoers(5). But this really belongs on Superuser. Commented Dec 21, 2010 at 19:35
  • 1
    I found this by googling. I don't think people googling their problem care whether this is on StackOverflow or Superuser or ServerFault. Commented Apr 20, 2011 at 18:31
  • I get the same error as cloning new branch using svn, putting option -m will get rid of this error Commented Feb 19, 2014 at 7:18

3 Answers 3

4

Running commands through sudo doesn't start a login or "interactive" shell so adding it to various bashrc or profile resource files won't help.

As DES said, the quick and dirty way is:

sudo env "SVN_EDITOR=$SVN_EDITOR" svn propedit svn:ignore .

But as derobert commented, the better more permanent solution is to run sudo visudo to edit /etc/sudoers , and add SVN_EDITOR to the env_keep option.

Sign up to request clarification or add additional context in comments.

2 Comments

This command just opened the file svn-prop.tmp for me. What to do there?
@pal4life that is what SVN_EDITOR is for... in this case svn propedit opens the editor so you can edit the properties as a text file.
2

sudo cleans out most of your environment before running the command. This is a Good Thing™. The quick-and-dirty workaround is to use env:

sudo env SVN_EDITOR=$SVN_EDITOR svn propedit svn:ignore .

Defining SVN_EDITOR in ~root/.bashrc should work, but a better solution is to define it in /etc/profile so every user gets the same value.

2 Comments

Thanks for the clear answer. I defined it at the bottom of /etc/profile and it's still not working (exited ssh and reopened a new session first). Any other ideas?
Try /etc/bashrc instead (I thought it sourced /etc/profile?)
0

~/.bashrc

As I recall .bash_profile is called on connection. (when you ssh to the machine) and .bashrc is called for each bash proccess start. But I could have this backwards.

Centos is one of the few distros that honor this rigorously these days. To my knowledge.

4 Comments

cool, i will try that. since I am using sudo, do I set the editor for myself or for the root user?
~/.bashrc for the desired user. You might have issues if root has no home, but then that begs the question why you need root to svn commit, but you surely have your reasons.
Sorry, not sure which user you mean by the "desired" user. And I don't need to use sudo to commit, just to make svn local edits. BTW, I didn't configure this system (the person who did was fired and not replaced :-/ ).
Oh how I remember those days. So you need to make edits on the production server for the "bad days". So what you -really- should be doing is sudo su - deploy (if deploy owns the svn checkout) and in /user/home/deploy/.bashrc add it there. If your site is running as root and not a user like deploy or www-data than thats just scary.

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.