Where is the environment variable written? - environment-variables

I am using Yocto, when i run command env, i could see couple of variables have been set. But when I open up /etc/environment, those variable is not in there.
When i set variable in /etc/environment, for example, proxies, it is not reflected to my system.
How can I know where's the environment variable file?
Thank you.

Yocto environment is set by executing oe-init-build-env script. You can add bitbake variables in local.conf file.

Related

Setting and accessing environmental variable used by rundeck

I have Rundeck 2.10.6-1 installed on a Ubuntu 16.04.4 LTS server and would like to set environmental variables just for rundeck. Rundeck itself is functioning normally.
I am able to set the environmental variables in /etc/environment for system-wide availability, but I'd like them to be accessible only by the rundeck session. One of them is SQLCMDPASSWORD, a plain text password, utilized by SQLCMD, so I'd like tighter access. We ended up using this approach for PSQL as well.
I have the rundeck $HOME directory identified as /var/lib/rundeck and the $USER name confirmed as 'rundeck'.
I find that adding environmental variables to .bashrc, .bash_profile, or .profile in that directory are not utilized by 'rundeck' as confirmed with a commandline job executing only 'printenv'. When logged in to the server as 'rundeck' I see the variables.
Am I setting these in right place?
So, no, those variables were not set in the correct place. Here's why...
There were some clues in the answers to this question and this question but neither was sufficient. Applications have their environmental variables set in their profile, and for rundeck that would be
$ more /etc/rundeck/profile
Second clue is from the head of that file which, loosely quoted, indicates
NOTE: DO NOT MODIFY THIS FILE. It will be replaced when the package is upgraded and your changes will not be saved. To override variables in this file, you can instead create a file at: /etc/default/rundeckd
So, I created that default file and set my environmental variables by adding the following content
export SQLCMDUSER=batman
export SQLCMDPASSWORD='secret_bat_password'
Now it works as intended.

Scons doesn't use my environment variables such as PATH and LD_LIBRARY_PATH

I have a little problem.
I source a script which changes my RedHat environment (PATH, LD_LIBRARY_PATH, etc.i).
When I launch my install with scons, it charges the default Environment from my machine, but not the current that I loaded...
I tried several attempts, but it was not conclusive. Most of the answer on the net are relative to a change on one variable which have to be set in the SConstruct.
How can I tell scons to charge the current Environment, but not the default ?
Thanks in advance !
The SCons way would be to set these environment variables in your SConstruct/SConscripts so that every user would end up with a reproducible build environment.
Take a read of the FAQ for this: http://scons.org/faq.html#Why_doesn.27t_SCons_find_my_compiler.2BAC8-linker.2BAC8-etc..3F_I_can_execute_it_just_fine_from_the_command_line.
SCons does not automatically propagate the external environment used to execute 'scons' to the commands used to build target files. This is so that builds will be guaranteed repeatable regardless of the environment variables set at the time scons is invoked. This also means that if the compiler or other commands that you want to use to build your target files are not in standard system locations, SCons will not find them unless you explicitly set the PATH to include those locations.
Already found the solution after some more search : env = Environment(ENV = os.environ)

how to add variable into the run configuration Eclipse

I'm using Eclipse Keplero in C++. I've a project that depends on other shared libraries.
To debug the application I've to add manully all dependency libraries, but this is very boring. So I thought that I can update PATH enviorment variable from "Enviorment" in "Run Configuration". I added the followin variable:
PATH:${PATH};${workspace_loc}\library\lib\x64;${BOOST_X64_NATIVE}
BOOST_X64_NATIVE is an os enviorment variable (windows 7). But I've the following message: Reference to undefined variable PATH.
Well how can I set correctly enviorment variables on eclipse in a way I haven't to copy every time all dependencies.
Just adjust the PATH enviorment variable:
On Run Settings -> Enviorment adjust the PATH variable. Note if you want to use an existing enviorment variable you have to use ${env_var:NAME} where NAME is the name of the variable. So to add update the PATH befor the deployment of the program you have to add PATH variable ${env_var:LIBRARY_PATH};${env_var:BOOST_X64_NATIVE};${env_var:PATH}

MacBook OS X 10.8.2 ant unable to find custom environment variables

When I run targets on ant it says it is unable to locate the variable I passed to it.
Config for environment variables :
in build.xml
<property environment="Env"/>
but I am unable to find the parameter defined parameter with
${Env.CATALINA_HOME}
where in the .bash_profile
export CATALINA_HOME=/Users/olgunkaya/development/apache-tomcat-7.0.34
and export PATH=${PATH}:$CATALINA_HOME
What can I do to achive this ?
Before you run ant, check to see if CATALINA_HOME is actually defined as an environment variable. I bet you'll find it isn't. Ant doesn't read your .profile or .bash_profile before starting, so if it's not already defined in your environment, Ant won't see it.
As you've seen opening a terminal window on a Mac doesn't necessarily guarantee that the .bash_profile file is executed. Try setting up these environment variables in .bashrc file instead.
Or, you can force .bash_profile to run by setting it as the Startup file in Terminal. Select File->Preferences from the menu, go to the Shell tab, select your default shell, and then click the Run Command checkbox and put .bash_profile in there. That will guarantee that .bash_profile is executed with each new terminal window.
I had a similar problem when referencing a custom variable, which was definitely defined in the shell spawning ant.
The solution was to EXPORT the variable when defined (in ~/.profile), so the shell would pass it to its children.

How to set Environment variables using Ant

It looks like this question has been asked many times. I searched but I could not get the answer
I am looking for techniques on how to set environment variables in Windows system using Ant
I have around 10 environment variables that needs to be set before I can start the compile using Ant
I am running on Windows system.
any help would be appreciated
Thank you,
Karthik
There is no way to set environment variables through Ant.
The property task can only be used for getting the value of an already set environment variable.
You would need to call Ant's exec task and pass the command line (for your operating system) to set the value of an environment variable.

Resources