Xinglab / rmats-turbo

Other
232 stars 55 forks source link

build_rmats --conda issue: Run 'conda init' before 'conda activate' #420

Closed AngelosKoz closed 4 months ago

AngelosKoz commented 4 months ago

Hello,

So after cloning the repository and installing all the dependencies, I am trying to run build_rmats --conda, but keep getting the following error:

build_rmats --conda

WARNING: A conda environment already exists at '/home/angelosk/rmats_turbo_dir/rmats-turbo/conda_envs/rmats' Remove existing environment (y/[n])? n

CondaSystemExit: Exiting.

CondaError: Run 'conda init' before 'conda activate'

Running with y to remove existing environment:

WARNING: A conda environment already exists at '/home/angelosk/rmats_turbo_dir/rmats-turbo/conda_envs/rmats' Remove existing environment (y/[n])? y

Channels:

  • defaults Platform: linux-64 Collecting package metadata (repodata.json): done Solving environment: done

    Package Plan

    environment location: /home/angelosk/rmats_turbo_dir/rmats-turbo/conda_envs/rmats

Proceed ([y]/n)? y

Preparing transaction: done Verifying transaction: done Executing transaction: done

To activate this environment, use

$ conda activate /home/angelosk/rmats_turbo_dir/rmats-turbo/conda_envs/rmats

To deactivate an active environment, use

$ conda deactivate

CondaError: Run 'conda init' before 'conda activate'

Tried the following solutions in different combinations which I found for said error, but I am not sure what i am missing here, sorry if this happens to be lack of knowledge on my part. _The rmatspy36 is an environment where I installed specifically python 3.6.12 and Cython 0.29.21 before running

build_rmats --conda

source ~/.bashrc conda init bash conda init conda activate /home/angelosk/rmats_turbo_dir/rmats-turbo/conda_envs/rmats conda activate rmats_py36

As an extra step, I have tried to run the installation process without the --conda flag and it seems to be working, but again cannot run test_rmats, prompting to the same error. The following messages are prompted after running build_rmats for the second time (PAIRADISE and DARTS have also been cloned):

make[3]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' [ 85%] Built target BamTools-utils make[3]: Entering directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' make[3]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' make[3]: Entering directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' [ 86%] Linking CXX executable ../../../bin/bamtools make[3]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' [100%] Built target bamtools_cmd make[2]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' make[1]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/bamtools/build' rm -f to ignore nonexistent files since .dylib will only exist for mac cd bamtools/lib; rm -f .so .so. .dylib cd rMATS_C; make; make[1]: Entering directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/rMATS_C' cd lbfgs_scipy && make make[2]: Entering directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/rMATS_C/lbfgs_scipy' /usr/bin/gfortran -c -O2 -c -o lbfgsb.o lbfgsb.f /usr/bin/gfortran -c -O2 -c -o linpack.o linpack.f /usr/bin/gfortran -c -O2 -c -o timer.o timer.f make[2]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/rMATS_C/lbfgs_scipy' /usr/bin/gcc -I/usr/include -Wall -O2 -msse2 -funroll-loops -fopenmp -o rMATSexe src/main.c src/myfunc.c src/util.c lbfgs_scipy/lbfgsb.o lbfgs_scipy/linpack.o lbfgs_scipy/timer.o -L/usr/lib/x86_64-linux-gnu -lgsl -lgslcblas -lm -lm -lgfortran -lgsl -lgslcblas -lgomp -lblas -llapack make clean make[2]: Entering directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/rMATS_C' rm -rf util.o myfunc.o .o src/.o lbfgs_scipy/.o make[2]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/rMATS_C' make[1]: Leaving directory '/home/angelosk/rmats_turbo_dir/rmats-turbo/rMATS_C' cd rMATS_pipeline; python setup.py build_ext; running build_ext cp find ./rMATS_pipeline/build | grep so .; Loading required package: doParallel Loading required package: foreach Loading required package: iterators Loading required package: parallel Loading required package: nloptr Loading required package: PAIRADISE Loading required package: doSNOW Loading required package: foreach Loading required package: iterators Loading required package: snow Loading required package: getopt Loading required package: ggplot2 Loading required package: mixtools mixtools package, version 2.0.0, Released 2022-12-04 This package is based upon work supported by the National Science Foundation under Grant No. SES-0518772 and the Chan Zuckerberg Initiative: Essential Open Source Software for Science (Grant No. 2020-255193).

Loading required package: Rcpp Loading required package: Darts

Thank you in advance for any assistance.

EricKutschera commented 4 months ago

I think the error CondaError: Run 'conda init' before 'conda activate' would happen if the conda setup code isn't being run. build_rmats sources https://github.com/Xinglab/rmats-turbo/blob/v4.3.0/setup_environment.sh#L21 which sources your .bashrc which should have lines like:

# >>> conda initialize >>>
__conda_setup=...

Maybe there is some other code in your .bashrc which prevents the conda setup from being run from a non-interactive script. You could try copying that conda setup code directly into build_rmats before the conda activate command. If that doesn't work I would suggest trying to make a very minimal example of conda activate not working for you from a bash script and posting that to https://github.com/conda/conda/issues

Your build without --conda looks like it worked and you should be able to run python rmats.py --help. It's not necessary to run test_rmats. That script uses a different conda environment to run automated tests. Since conda activate is not working for you with these scripts I don't think you'll be able to run test_rmats

AngelosKoz commented 4 months ago

I think the error CondaError: Run 'conda init' before 'conda activate' would happen if the conda setup code isn't being run. build_rmats sources https://github.com/Xinglab/rmats-turbo/blob/v4.3.0/setup_environment.sh#L21 which sources your .bashrc which should have lines like:

# >>> conda initialize >>>
__conda_setup=...

Maybe there is some other code in your .bashrc which prevents the conda setup from being run from a non-interactive script. You could try copying that conda setup code directly into build_rmats before the conda activate command. If that doesn't work I would suggest trying to make a very minimal example of conda activate not working for you from a bash script and posting that to https://github.com/conda/conda/issues

Your build without --conda looks like it worked and you should be able to run python rmats.py --help. It's not necessary to run test_rmats. That script uses a different conda environment to run automated tests. Since conda activate is not working for you with these scripts I don't think you'll be able to run test_rmats

Thank you very much this worked like a charm, all i had to do was add in both the build_rmats (after local CONDA_ENV_PATH="${SCRIPT_DIR}/conda_envs/rmats") and setup_environment.sh (before first function) scripts the conda initialize part from the bashrc. Again thank you for the fast and accurate response.

# >>> conda initialize >>>
__conda_setup=...
...
unset __conda_setup
# <<< conda initialize <<<