Can I set environment variables in environment.yml files in conda environments?
Conda lets me save environment variables in environments via the env_vars.sh script, but is there a way to automate the process of creating env_vars.sh files in the activate.d, deactivate.d directories according to some specification of environment variables within environment.yml, for a reproducible environment with, say, MKL_THREADING_LAYER=GNU?
It looks like this was added in Conda v4.9!
There is documentation at https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#setting-environment-variables
Environment variables set using conda env config vars will be retained in the output of conda env export. Further, you can declare environment variables in the environment.yml file as shown here:
name: env-name
channels:
- conda-forge
- defaults
dependencies:
- python=3.7
- codecov
variables:
VAR1: valueA
VAR2: valueB
Older versions of conda will complain;
EnvironmentSectionNotValid: The following section on 'environment.yml' is invalid and will be ignored:
- variables
Related
I am writing a docker file in which at one specific step I am generating dynamic secret file which contains a lit of approx 20 env. variables, in below stand format:
export ABC=‘XXXXXXX’
export DEF=‘XXXXXXX’
export GHI=‘XXXXXXX’
export JKL=‘XXXXXXX’
…
I want to set all this variables values in env. variables.
I ran below command but unable to set this values in ENV
RUN . ./secrets/env
But it's unable to set all export variables as env. variables
The current option I am using now is as below:
ENV ABC ${xxxx}
Is there option available to set all secret file values as Env. values.
I'm doing an internship (= yes I'm a newbie). My supervisor told me to create a conda environment. She passed me a log file containing many packages.
A quick qwant.com search shows me how to create envs via the
conda env create --file env_file.yaml
The file I was give is however NOT a yaml file it is structured like so:
# packages in environment at /home/supervisors_name/.conda/envs/pancancer:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
bedtools 2.29.2 hc088bd4_0 bioconda
blas 1.0 mkl
bzip2 1.0.8 h7b6447c_0
The file contains 41 packages = 44 lines including comments above. For simplicity I'm showing only the first 7.
Appart from adding env name (see 2. below), is there a way to use the file as it is to generate an environment with the packages?
I ran the cmd using
conda env create --file supervisors.log.txt
SpecNotFound: Environment with requirements.txt file needs a name
Where in the file should I put the name?
alright, so, it seems that they give you the output of conda list rather than the .yml file produced by conda with conda env export > myenv.yml. Therefore you have two solutions:
You ask for the proper file and then proceed to install the env with conda built-in pipeline
If you do not have any access on the proper file, you could do one of the following:
i) Parse with python into a proper .yml file and then do the conda procedure.
ii) Do a bash script, downloading the packages listed in the file she gave you.
This is how I would proceed, personally :)
Because there is no other SO post on this error, for people of the future: I got this error just because I named my file conda_environment.txt instead of conda_environment.yml. Looks like the yml extension is mandatory.
On FreeBSD, I need NODE_ENV=production and other systemwide environment variables to be set on startup, before nginx fires up.
Which is the right place i.e. file I do that?
Also, if you'd like to set some environment variables for an rc(8) service then you might also take a look at the ${name}_env and ${name}_env_file variables described in rc.subr(8). They allow you to set environment variables for services on FreeBSD in rc.conf(5), e.g.:
nginx_enable="YES"
nginx_env="NODE_ENV=production"
One option could be to add your environment variables to /etc/login.conf in the setenv capability, for example:
default:\
:passwd_format=sha512:\
:copyright=/etc/COPYRIGHT:\
:welcome=/etc/motd:\
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,NODE_ENV=production:\
...
From the login.conf man:
setenv list A comma-separated list of
environment variables and
values to which they are to
be set.
If you modity the /etc/login.conf file, don't forget to run:
cap_mkdb /etc/login.conf
I am trying to do "unset" of an env variable from my rpm.spec file. which is not happening
Note that i am not exporting that env inside my rpm.spec.(i will do an export my self in cmd line)
$export user=akshatha
$export group=akshatha1
rpm.spec:
%postun
unset user
unset group
uninstalling the package:
$rpm -e (rpm_package)
check whether the value is unset or not(which is not unset):
$ echo $user
akshatha
$echo $group
akshatha1
You are mixing up what an rpm package is and what it can do.
Environment variables are set within a (bash, shell,...) Session. When you set variables and you start a new session, these variables are gone.
Rpm packages are supposed to install files at certain locations, to make permanent, system wide changes (like installing software). An rpm package, nor the installation of an rpm package is linked to your bash session (the installation will run in a separate session by the way).
You should not try to influence your environment variables with your rpm.
In the very unlikely case that you do need to export some kind of environment variable, then you should try to make it system wide available, for example declaring it in /etc/bashrc or something similar.
I created a a .yml file from a well stable conda env.
The .yml file states the following at the end which basically points to other packages that cannot be obtained from conda channels:
- pip:
- easygui==0.98.1
- nptdms==0.12.0
When creating a new env using this .yml file, it completely avoided installing these two packages. Is that something the user has to do manually? If yes, doesn't that defeat the purpose of creating-sharing .yml env file?