openforis / sepal

Geographical Data Processing in the Cloud
https://sepal.io/
MIT License
203 stars 45 forks source link

how to save environment variable in SEPAL ? #251

Open 12rambau opened 1 year ago

12rambau commented 1 year ago

In the test suit of sepal-ui I need to set some parameters in the environment such as a earthengine token and planet credentials. So far we were creating a .bash_profile file to do this.

Recently I was scanning the hidden files of the new home folder and found a .profile one:

In https://sepal-ui.readthedocs.io/en/latest/start/contribute.html#env-for-planet-components we suggest to create a .bash_profile file to the developers of the lib. It should work on local computers but will break SEPAL instances initialization.

Looking at the .profile in my account I found:

 # ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

meaning that if .bash_profile exist then the bins are not correctly instanciated (and the coloring and other prettifying stuff) right ?

If I want to permanently add extra environment variable instead of eporting them all the time, should I copy/paste this content in my .bash_profile (with the risk of missing any update) or is there another way ?

TmtStss commented 1 year ago

As a frequent Sepal user, I back up the need for being able to use environment variables.

So far, it looks I have a denied permission to add environment variables to the .bashrc file. When I try to edit the .bashrc file in the shell text editor it also mentions: 'File is unwriteable'. See example code here below.

sepal-user@xxxxxxxxx:~$ echo "export DATACUBE_LOCATION='/path/to/datacube'" >> ~/.bashrc
-bash: /home/sepal-user/.bashrc: Permission denied