question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Executing a command via terminal works fine, but fails when executed as a Eclipse-Che-Command

See original GitHub issue

I 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 location cmake -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:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
sg82fecommented, Jun 2, 2017

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:

if [ -d "$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
for envfile in $OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
source $envfile
done
fi

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

0reactions
mdnasrcommented, Jan 19, 2020

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 using shopt.

shopt -s expand_aliases
source environment-setup-corei7-64-poky-linux

Also see this Stackoverflow answer

Read more comments on GitHub >

github_iconTop Results From Across the Web

shell script works fine when executed in terminal, but errors ...
but when i add to my existing shell script which is running as a concurrent program, the program errors out throwing the error...
Read more >
Bash-script as linux-service won't run, but executed from ...
The problem is that, when the script runs as a service, it does not run as "you": it does not have your environment....
Read more >
Bash script runs manually, but fails on crontab - Stack Overflow
To fix this, first print your path in the manual environment ( echo $PATH ), and then manually set up PATH at the...
Read more >
How to fix a "Command not found" error in Linux - Red Hat
When you're trying to run a command (with or without sudo ) and get an error message that reads "Command not found," this...
Read more >
Enter administrator commands in Terminal on Mac
To run commands with superuser privileges, use the sudo command. sudo stands for superuser do. The following example works on computers with macOS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found