Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running ubuntu 12.04 LTS and working with eclipse (juno) on a c++ project. I keep getting "TERM environment variable not set" in the console while trying to run the program. I realize this means the variable needs to get set. My question is what should it be set to and how do I set it?

I've read that it should be 'xterm' in a few places. So I added

export TERM=xterm

in my .profile and while eclipse stopped giving me the warning, instead it would output unreadable garbage everynow and then (not a side effect of the program). It did display the program output but intermixed were weird characters. This leads me to believe it's not 'xterm' I should be setting TERM to. Or I'm setting it in an incorrect way.

Any help is appreciated.

Sample output:

**TERM environment variable not set.**


Please make a selection
-----------------------
1. Create a budget
2. Edit a budget
3. Display a budget
4. Save a budget
5. Load a budget
6. Exit

What is your selection: 1
**TERM environment variable not set.**
Enter the name of your budget: 

etc

The program continues to execute as expected but the message is highly annoying

  • As someone has commented, I do use system("clear") which is likely the source of the warning? Either way, is this likely just an eclipse issue or something I can fix in ubuntu/linux
share|improve this question
    
Are you using Lubuntu or Xubuntu? –  green7 Sep 14 '12 at 8:13
add comment

1 Answer

"It did display the program output but intermixed were weird characters" How about posting the output?

The problem might be that Eclipse runs the program not inside of a regular terminal, but its own console. Did you try to run the program from regular terminal, outside of Eclipse?

My suspicion is that the Eclipse runs the program as if it was a non-interactive program, in a non-interactive setting, where the TERM variable is not needed. However, it might be that your program in fact uses a system call (something like system( "clear" )) that in fact requires the TERM variable in order to work.

Unfortunately, I never use Eclipse, so I'm just guessing.

EDIT: Yeah, that's the way it is: system( "clear" ) requires a terminal, but Eclipse does not provide terminal capabilities for your program. Solution:

(i) Run the program from command line in a terminal

(ii) Go to Eclipse settings and tell it to start the program using gnome-terminal. Apparently, there is a description how to do it here.

share|improve this answer
    
Yes I do call system("clear") only because I am testing the program via console before I create a GUI. I'm sure there is a better cross platform call to make other than system("clear") but that's a quick easy way at least in linux. –  Robert Sep 15 '12 at 3:20
    
I've added sample output –  Robert Sep 15 '12 at 3:26
    
@Robert I think we have a solution now, I edited my answer. –  January Sep 15 '12 at 7:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.