Executing a command via terminal works fine, but fails when executed as a Eclipse-Che-Command
See original GitHub issueI did not find a similar issue, so i started this one.
I have a C++ project that is hosted on git.
The project can be build via cmake and make.
There is a specific SDK (poky-compiler/linker/… etc - created with yocto) to cross-compile the C++ project for another hardware.
So what is working fine in che is:
-
I imported the project (git)
-
I use the Terminal to build the project what works fine:
cd /opt/poky/2.1
source environment-setup-corei7-64-poky-linux
// setup environment (correct compiler…)cd /projects/myProject
// go to the CMakeLists.txt locationcmake -Dmytargetapp=On
// run cmake succesfully builds the executable ‘make’ // build it -
So this works fine in the terminal console of Che, the project is build (compiled and linked)
-
But in case i create a Che command by combining the steps done in Terminal: ( source /opt/poky/2.1/env-setup && cmake && cmake) I get this error at the cmake stage:
cmake -Daracomex=ON … && make – The C compiler identification is GNU 4.9.3 – The CXX compiler identification is GNU 4.9.3 – Check for working C compiler: /opt/poky/2.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc – … – … CMake Error at /opt/poky/2.1/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.4/Modules/FindBoost.cmake:1247 (message): Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost’s headers. Call Stack (most recent call first): CMakeLists.txt:224 (find_package)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: – Configuring incomplete, errors occurred! Boost_INCLUDE_DIR (ADVANCED) used as include directory in directory /projects/public-sample-repo See also “/projects/public-sample-repo/output/CMakeFiles/CMakeOutput.log”. See also “/projects/public-sample-repo/output/CMakeFiles/CMakeError.log”.
for completeness, here are the lines from CMakeLists.txt
218 # Dependency management of 3rd party libraries
219 #
220 # Threads
221 find_package(Threads REQUIRED)
222
223 # Boost
224 find_package(Boost COMPONENTS program_options REQUIRED)
225 set(Boost_USE_STATIC_LIBS ON)
226 include_directories(${Boost_INCLUDE_DIRS})
It might be none-che Issue, but i don’t understand why the behaviour is different between Terminal and Command.
Reproduction Steps: as described above.
OS and version: Ubuntu 16.04 LTS
same behaviour on RedHat Linux and Che 5.9.0 / 5.10.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top GitHub Comments
Meanwhile i could a little isolate and also ‘solve’ the problem. To Summarize so basically the sourcing of the file works in the command, what seems to be what was not working is an alias for the cmake(?)
Long Story: I believe it makes no difference if i source the script in the che command by
source /opt/poky/2.1/source environment-setup-corei7-64-poky-linux && cmake && make
or i put the whole content of the shell-script into the command$ export PATH=.... && ... && ... && make
My observation after testing many variations is: The behaviour is the same, the environmentvariables that are set in the (non-interactive)shell / process are set correct and can be verified.The shell script contains some inclusion of further sourcing:
The result of the conditional looped inclusions/sourcing evaluates to one line in console. It is an alias:
alias cmake="cmake -DCMAKE_TOOLCHAIN_FILE=/opt/poky/2.1/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake"
And now the strange thing
What is not working:
source environment-setup && echo $PATH && echo alias cmake && cmake -Dtarget=ON
everything looks perfect, the alias of cmake is as expected - But I get the error executing cmake, with not finding the Boost Libraries.What is working:
source environemnt-setup && echo $PATH && echo alias cmake && cmake -DCMAKE_TOOLCHAIN_FILE=/opt/poky/2.1/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake -Dtarget=ON
ignoring the alias, and writing the cmake command with all arguments, this is working perfect - no error at Boost libraries, and the output is exactly the same as i would have done everything manually in a user-interactive terminal console.(Checked with Beyond compare)
So i have a workaround/solution- i can use the eclipse che command
source env-setup && cmake -DCMAK_TOOLCHAINFILE=/...bla && cmake -Dmytarget=ON
But still this alias behaviour makes me curious
I have faced the same problem, and I have found that aliases are not expanded when the shell is not interactive, unless the
expand_aliases
shell option is set usingshopt
.Also see this Stackoverflow answer