问题描述
在OSX上使用CLion,我正在创建一个简单的控制台应用程序,我想在其中执行system("clear")
.当我在OSX终端中运行该应用程序时,它可以正常工作.当我使用CLion终端运行它时,system("clear")
失败,并显示以下消息:
Using CLion on OSX, I'm creating a simple console app in which I want to do a system("clear")
. When I'm running the app in the OSX terminal, it works without issue. When I run it using the CLion terminal, the system("clear")
fails with message :
我首先尝试手动将其设置在我的cmakelists.txt
文件中,但没有成功
I first tried to manually set it in my cmakelists.txt
file without success by doing
set(ENV{TERM} "xterm-256color")
然后,我尝试使用以下键/值对(环境选项)在构建",执行"和部署"的控制台"和"CMake"部分的CLion设置中手动设置它(随后完全重新启动):
I then tried to manually set it (followed by full restart) in CLion settings for both Console and CMake sections in Build, Execution, Deployment using the following key/value pair (Environment option):
TERM xterm-256color
在我的OSX终端中,执行env | grep TERM
打印
In my OSX terminal, doing a env | grep TERM
prints out
TERM_PROGRAM = Apple_Terminal
TERM_PROGRAM=Apple_Terminal
TERM = xterm-256color
TERM=xterm-256color
我想念什么?不幸的是我找不到它...
What am I missing? I unfortunately can't find it...
推荐答案
最终找到了此修复程序.您必须不在控制台中添加环境变量TERM=xterm-256color
或在运行/调试"配置中添加CMake配置错误.
Finally found the fix. You must add the Environment Variable TERM=xterm-256color
not in the Console or the CMake config bug in the your Run/Debug configuration.
这篇关于如何在CLion中正确设置环境变量TERM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!