Search code examples
terminalenvironment-variablesvirtualenvclion

How to set the environment of the CLion built-in terminal to be the same as that of the system terminal. For example/usr/lib directory content


I'm having trouble using the CLion integration environment under linux.

When I execute a script using the system terminal, it is possible to run. compile_test.sh:

#!/bin/bash

if [ ${USER} == "mzflrx" ]
then
  LLVM_PATH="/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04"
else
  LLVM_PATH="/home/devin812/文档/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04"
fi

# 生成待保护的字节码
${LLVM_PATH}/bin/clang -o3 -emit-llvm test.c -c -o test.bc

# 生成可执行文件(保护前)
${LLVM_PATH}/bin/clang test.bc -o test -lpthread

But when I execute with CLion's built-in terminal, I get the following error:

[mzflrx@mzflrx test]$ ls
compile_out_cpp.sh   compile_test.sh  out1     out.bc      test          test-37.cpp  test.c    test.i64
compile_out.sh       data.txt         out1.bc  out.i64     test-377.cpp  test-37.ll   testcase  test.ll
compile_test_cpp.sh  generate_cpp.sh  out1.ll  result.txt  test-37.bc    test.bc      test.cpp  test_time.py
[mzflrx@mzflrx test]$ ./compile_test.sh 
/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/llvm-dis: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

I don't know why I can't find the library.

In the CLion built-in terminal, I go into the /usr/lib directory to execute the ls command.

[mzflrx@mzflrx test]$ cd /usr/lib
[mzflrx@mzflrx lib]$ ls
aarch64-linux-gnu    extensions      ld-linux-aarch64.so.1  locale      perl5      systemd   udev
arm-linux-gnueabihf  gcc             ld-linux-armhf.so.3    os-release  python3.8  tcl8.6    x86_64-linux-gnu
debug                i386-linux-gnu  ld-linux.so.2          perf        sdk        terminfo

In the linux terminal, I go into the /usr/lib directory to execute the ls command.

$: cd /usr/lib                                                                                    
$: ls | head -n20                                                                                                                       
accounts-daemon
alsa-lib
ao
apparmor
appimagelauncher
appstreamcli-compose
asb-plugins-5
at-spi2-registryd
at-spi-bus-launcher
audit
avahi
awk
baloo_file
baloo_file_extractor
baloorunner
bash
bellagio
bfd-plugins
binfmt.d
bluetooth    

Twice the same command gets completely different results on different consoles.

I don't know why, is it because the CLion built-in console is using a virtual environment?

But it's no use removing active-virtualenv option from the file->setting->Tool->Terminal


Solution

  • I know why there is such a reason. Because I use flatpak to install, it has its own virtual environment. It's fine after I use the source code to install