How to properly set environment variable TERM in CLion - cmake

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 :
TERM environment variable not set.
I first tried to manually set it in my cmakelists.txt file without success by doing
set(ENV{TERM} "xterm-256color")
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
In my OSX terminal, doing a env | grep TERM prints out
TERM_PROGRAM_VERSION=388
TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
What am I missing? I unfortunately can't find it...

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.

Related

SBT can't read environment variables in IntelliJ

I defined a new environment variable in ~/.zshrc like that: export JVM_XMX=-Xmx2048M. I can verify that it was set correctly running export command and finding it in the list.
Now I want to use it in SBT. I've tried these two approaches:
sys.env("JVM_XMX")
sys.env.get("JVM_XMX")
But the value couldn't be found or the Option is None. Errors that I see are:
NoSuchElementException: key not found: JVM_XMX
NoSuchElementException: None.get
What I also tried was to add the variable into SBT in IntelliJ Settings. I went to Build, Execution, Deployment -> Build Tools -> sbt and set VM parameters to -DJVM_XMX=-Xmx2048M. It didn't help.
Anyone knows how to setup SBT to work with IntelliJ correctly?
Versions used:
sbt 1.2.8
IntelliJ IDEA 2019.2.1
As a workaround I was able to use system properties (scala.sys.SystemProperties). This works because this is the way how to find values added into SBT in IntelliJ Settings.
Code example from build.sbt:
sys.props.get("JVM_XMX")
UPDATE:
I was finally able to figure out what was the real problem. My .bashrc file was incorrectly set up (I had the variables only in .zshrc). After adding environment variables into correct rc file, the problem was fixed.
If you'd like this property to be part of your project, and not only in your solution, you can add a file names ".sbtopts" at the root of your repository, next to the build.sbt file.
In this file you can configure the JVM options.
For instance you can add there:
-J-Xmx2048M
I couldn't find the sbt documentation supporting my suggestion, but it works for me :)
I was able to work around this issue by going to Preferences -> Build, Execution, Deployment -> Build Tools -> sbt, then enabling sbt shell for builds and project reload.

Cannot configure QtCreator using CMake on Ubuntu 18.04

I am trying to setup a project based on CMake with QtCreator.
In Projects I defined the Build Steps I need.
In the Build setting I get constantly the error message:
Failed to activate protocol version: "CMAKE_GENERATOR" is set but incompatible with configured generator value
I tried to browse on the Internet for this problem but I could not get rid of this error.
If now I however try to build my project specifying a target, my compile steps are not executed, instead, I get the following message:
Running "/usr/local/bin/cmake -E server --pipe=/tmp/cmake-W2VOXm/socket --experimental" in xxxx/.Build/release.
CMake Project parsing failed.
Parsing of CMake project failed: Connection to CMake server lost.
Restarting QtCreator does not help, each time the project is opened the message happens again.
Make sure the build directory it's in the same directory than your projects is, like this:
I got a similar error and have fixed it.
Try to reinstall cmake in Ubuntu by follwing https://cgold.readthedocs.io/en/latest/first-step/installation.html#ubuntu.
Configurate Tools - Options - build & run regarding "cmake" and "kits". Make sure that one of the configurations (auto-detected or maunal) is corrected.
restart qt creator, open project and "run cmake" again.
I have seen and resolved this issue previously by just deleting the build folder, reloading qtcreator and rerunning cmake.

How to switch PHP versions in environment variables?

Since I'm required to work on both PHP5.x and PHP7.x projects in Yii framework, I've installed WAMP.
I've also set up my environment variables to link to both paths containing php.exe and for just working with the projects, that's just fine.
However, whenever I need to run migrations, there's a problem: if PHP7 path is defined first, PHP5 migrations won't run and if PHP5 path is listed first, PHP7 migrations won't work anymore.
Error message for PHP5:
'yii' is not recognized as an internal or external command, operable program or batch file.
Error message for PHP7:
Parse error: syntax error, unexpected '?' in C:\wamp64\www\project\vendor\phpunit\phpunit\src\Framework\TestCase.php on line 822
Is there a clean way to be able to define which PHP version you wish to use when running migrations, without having to reconfigure your environment variables again and again?
Thank you #RiggsFolly for your help. Based on the link you provided, I compiled a handy solution:
I started off by creating 2 new files in C:\Windows\System32 (since this path is already included in the environment variables):
startphp5.cmd and startphp7.cmd.
startphp5.cmd contains just this (start7.php is obviously almost the same):
PATH=%PATH%;C:\wamp64\bin\php\php5.6.31
php -v
Before running my migrations in my command prompt, all I have to do now is run either "startphp5" or "startphp7".

How do I run a EXE Go executable from within IntelliJ IDEA?

I have a Go program which I'm working on in IntelliJ IDEA on a Windows machine. The program's structure is a little unconventional (don't want to go into detail here as its besides the point) because of which I first have to compile the program using the following command:
go build -o cli.exe
And then I can run cli.exe directly in the command prompt.
But how do I configure the run configuration in IntelliJ IDEA so that it doesn't mind running a Windows executable ? Because if I try to tell it to run an EXE file as it's run configuration, it gives me error "Main file is invalid"
How do I solve this ?
Make sure you have a file name (not a folder name) in field File on Run/Debug Configuration window (In IntelliJ IDEA go to menu Run->Edit Configuration...->your_configuration). That was my case.
You may be able to install the Bash plugin on Windows, then create a run configuration using the Bash plugin, and just run your executable from a script.
Create a Go Application run configuration and that should work. You can choose to run either a file or a package. If you would share more details then the answer would be more complete. If you still have an issue with this, please open an issue to the bug tracker and I'll be able to help out (please follow the issue template there).

On UnsatisfiedLinkError, clarification needed

When building the project from command line using mvn clean install everything builds without any issues.
When running some tests that use precompiled C libraries from IntelliJ, tests fail with java.lang.UnsatisfiedLinkError
I may be completely off here, but does IntelliJ not see the .so file? Is so, how can it be added please?
Shared library fails to load with UnsatisfiedLinkError if:
it's not in the working directory configured in the test run configuration.
it's not in PATH environment (on Mac Terminal and GUI apps have different environment, see this answer). Run IDEA from the Terminal open -a /Applications/IntelliJ\ IDEA\ 12.app/ to make environment the same.
it's not in the location specified using -Djava.library.path VM option.
.so depends on some other library that is not found for any of the 1-3 reasons (or the dependency of that dependency is not found, etc).