ContinuumIO / anaconda-issues

Anaconda issue tracking
648 stars 222 forks source link

GCC package doesn't add environment variables in fish shell #11624

Open edisongustavo opened 4 years ago

edisongustavo commented 4 years ago

Actual Behavior

My shell is set to fish shell.

When using the compiler tools (gcc_linux-64 or gxx_linux-64) the environment variables required to use these compilers are not set when using a fish shell:

This differs from what happens when using bash where all the environment variables are correctly set.

This happens because the package gcc_linux-64 only provides 1 activation file: etc/conda/activate.d/activate-gcc_linux-64.sh and not a fish version.

Expected Behavior

The environment variables are correctly set.

Steps to Reproduce

Grab environment variables in fish:

(base) $ conda activate gcc-defaults
(gcc-defaults) $ env | sort > env-fish.txt

Grab environment variables in bash:

(base) $ bash
(base) $ conda activate gcc-defaults
(gcc-defaults) $ env | sort > env-bash.txt

Now the diff:

``` $ diff env-bash.txt env-fish.txt 1,3d0 < ADDR2LINE=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-addr2line < AR=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-ar < AS=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-as 6d2 < CC=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-cc 9d4 < CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/edisongustavo/miniconda3/envs/gcc-defaults/include 11d5 < CMAKE_PREFIX_PATH=/home/edisongustavo/miniconda3/envs/gcc-defaults:/home/edisongustavo/miniconda3/envs/gcc-defaults/x86_64-conda_cos6-linux-gnu/sysroot/usr 13,14d6 < CONDA_BACKUP_HOST=x86_64-conda_cos6-linux-gnu < CONDA_BUILD_SYSROOT=/home/edisongustavo/miniconda3/envs/gcc-defaults/x86_64-conda_cos6-linux-gnu/sysroot 21d12 < _CONDA_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_conda_cos6_linux_gnu 23,25d13 < CPPFLAGS=-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/edisongustavo/miniconda3/envs/gcc-defaults/include < CPP=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-cpp < CXXFILT=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-c++filt 27,28d14 < DEBUG_CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem /home/edisongustavo/miniconda3/envs/gcc-defaults/include < DEBUG_CPPFLAGS=-D_DEBUG -D_FORTIFY_SOURCE=2 -Og -isystem /home/edisongustavo/miniconda3/envs/gcc-defaults/include 32,36d17 < ELFEDIT=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-elfedit < GCC_AR=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-gcc-ar < GCC=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-gcc < GCC_NM=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-gcc-nm < GCC_RANLIB=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-gcc-ranlib 44d24 < GPROF=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-gprof 48d27 < HOST=x86_64-conda_cos6-linux-gnu 62,66d40 < LDFLAGS=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/edisongustavo/miniconda3/envs/gcc-defaults/lib -Wl,-rpath-link,/home/edisongustavo/miniconda3/envs/gcc-defaults/lib -L/home/edisongustavo/miniconda3/envs/gcc-defaults/lib < LD_GOLD=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-ld.gold < LD=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-ld < LESSCLOSE=/usr/bin/lesspipe %s %s < LESSOPEN=| /usr/bin/lesspipe %s 70,72d43 < NM=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-nm < OBJCOPY=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-objcopy < OBJDUMP=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-objdump 81,82d51 < RANLIB=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-ranlib < READELF=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-readelf 85,86c54 < SHLVL=2 < SIZE=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-size --- > SHLVL=1 89,90d56 < STRINGS=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-strings < STRIP=/home/edisongustavo/miniconda3/envs/gcc-defaults/bin/x86_64-conda_cos6-linux-gnu-strip 96d61 < _=/usr/bin/env ```
Anaconda or Miniconda version:
(gcc-defaults) $ conda list gcc
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
gcc_impl_linux-64         7.3.0                habb00fd_1  
gcc_linux-64              7.3.0                h553295d_9  
libgcc-ng                 9.1.0                hdf63c60_0
Operating System:
cat ~/.config/fish/config.fish
``` # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! eval /home/edisongustavo/miniconda3/bin/conda "shell.fish" "hook" $argv | source # <<< conda initialize <<< ```
conda info
``` $ conda info active environment : gcc-defaults active env location : /home/edisongustavo/miniconda3/envs/gcc-defaults shell level : 2 user config file : /home/edisongustavo/.condarc populated config files : conda version : 4.8.2 conda-build version : not installed python version : 3.7.4.final.0 virtual packages : __glibc=2.27 base environment : /home/edisongustavo/miniconda3 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /home/edisongustavo/miniconda3/pkgs /home/edisongustavo/.conda/pkgs envs directories : /home/edisongustavo/miniconda3/envs /home/edisongustavo/.conda/envs platform : linux-64 user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.4 Linux/5.3.0-40-generic ubuntu/18.04.4 glibc/2.27 UID:GID : 627244133:600260513 netrc file : None offline mode : False ```
conda list --show-channel-urls
``` $ conda list --show-channel-urls # # Name Version Build Channel _libgcc_mutex 0.1 main defaults binutils_impl_linux-64 2.31.1 h6176602_1 defaults binutils_linux-64 2.31.1 h6176602_9 defaults ca-certificates 2020.1.1 0 defaults certifi 2019.11.28 py37_0 defaults gcc_impl_linux-64 7.3.0 habb00fd_1 defaults gcc_linux-64 7.3.0 h553295d_9 defaults ld_impl_linux-64 2.33.1 h53a641e_7 defaults libedit 3.1.20181209 hc058e9b_0 defaults libffi 3.2.1 hd88cf55_4 defaults libgcc-ng 9.1.0 hdf63c60_0 defaults libstdcxx-ng 9.1.0 hdf63c60_0 defaults ncurses 6.2 he6710b0_0 defaults openssl 1.1.1d h7b6447c_4 defaults pip 20.0.2 py37_1 defaults python 3.7.6 h0371630_2 defaults readline 7.0 h7b6447c_5 defaults setuptools 45.2.0 py37_0 defaults sqlite 3.31.1 h7b6447c_0 defaults tk 8.6.8 hbc83047_0 defaults wheel 0.34.2 py37_0 defaults xz 5.2.4 h14c3975_4 defaults zlib 1.2.11 h7b6447c_3 defaults ```
marcelotrevisani commented 4 years ago

cc: @jjhelmus

jjhelmus commented 4 years ago

The GCC activation packages are build from this recipe in the AnacondaRecipes/aggregate repository. Adding activation script for the fish shell would be a welcome addition but are not something that are a high priority for the Anaconda team.

rishabh-ranjan commented 1 year ago

any workaround for fish users in the meantime?

grhkm21 commented 1 year ago

@rishabh-ranjan Here is my temporary script for now. This probably won't work for you out of the box, but just tweak it a bit yourself. The most important variables are of course the first three lines. From there, I encountered an issue where it says #include <stdio.h> not found (on a dummy c file I tested). To debug that, do $CC a.c -v, and see where it's searching. Next, start another session that uses a normal shell (not sure what the terminology is, but I think it's called "UNIX-compatible") that works with the activate.sh files, then activate your conda environment, and run the same command $CC a.c -v. Then, look at env | grep ... and copy out the relevant environment variables, which in my case is SDKROOT, though I imagine it'll be different on non-Mac systems. Just repeat the process until you get all the environment variables. Looking at the activation source files at $CONDA_PREFIX/etc/conda/activate.d will also help, seeing what environment variables are set. I will see if I have time to port the files to .fish later.

#!/bin/bash

set -gx CC $CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-clang 
set -gx CXX $CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-clang++
set -gx FC $CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran

set -gx SDKROOT "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"

set -gx CXXFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $CONDA_PREFIX/include"
set -gx DEBUG_CXXFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -Og -g -Wall -Wextra -isystem $CONDA_PREFIX/include"
set -gx CFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem $CONDA_PREFIX/include"
set -gx DEBUG_CFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra -isystem $CONDA_PREFIX/include"
set -gx LDFLAGS_USED "-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,$CONDA_PREFIX/lib -L$CONDA_PREFIX/lib"
set -gx LDFLAGS_LD_USED "-pie -headerpad_max_install_names -dead_strip_dylibs -rpath $CONDA_PREFIX/lib -L$CONDA_PREFIX/lib"
set -gx CPPFLAGS_USED "-D_FORTIFY_SOURCE=2 -isystem $CONDA_PREFIX/include"

set -gx CMAKE_PREFIX_PATH_USED "$CMAKE_PREFIX_PATH:$CONDA_PREFIX"
set -gx CFLAGS "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem $CONDA_PREFIX/include"
KoljaFrahm commented 9 months ago

For me it worked after executing this: set -gx CONDA_BUILD_SYSROOT $CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot Would be useful to have conda working with fish natively though