title: WSL can't see environment variable
body: <p>I'm currently on the quest to getting a MIPS cross-compiler toolchain running within WSL, accessed by CLion. </p>
  
  <p>There, I'm having a strange issue with WSL. I have added the following to the <code>.bashrc</code>:</p>
  
  <pre><code>STAGING_DIR="/home/max/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16"
  export STAGING_DIR
  </code></pre>
  
  <p>Moreover I have the script <code>test.sh</code></p>
  
  <pre><code>#!/bin/sh
  
  echo "Staging dir is: " $STAGING_DIR
  </code></pre>
  
  <p>When using <code>wsl</code> to get a shell and execute the script, the output is as follows:</p>
  
  <pre><code>max@DESKTOP-ISH7UJQ:/mnt/c/Users/Maxi$ ./test.sh
  Staging dir is:  /home/max/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16
  </code></pre>
  
  <p>When using <code>wsl &lt;command&gt;</code> to execute a bash command within WSL, the output differs. The environment variable has simply dissappeared.</p>
  
  <pre><code>C:\Users\Maxi&gt;wsl ./test.sh
  Staging dir is:
  </code></pre>
  
  <p>It seems like the <code>.bashrc</code> (I've also tried <code>.profile</code>) is not executed when executing it via wsl?`</p>
  
  <p>This is a problem because when CLion invokes the WSL subsystem to build my C++ project using CMake, the compiler complains that this environment variable isn't there. </p>
  
  <p>When I manually get a shell and execute the <em>exact same</em> cmake command, compilation works without warnings since the environment variable is there. </p>
  
  <p>Inside CLion:</p>
  
  <pre><code>/usr/bin/cmake --build /mnt/c/Users/Maxi/CLionProjects/linux_wsl_test/cmake-build-debug-wsl_omega --target all -- -j 2
  Scanning dependencies of target linux_wsl_test
  [ 50%] Building CXX object CMakeFiles/linux_wsl_test.dir/main.cpp.o
  mipsel-openwrt-linux-g++: warning: environment variable 'STAGING_DIR' not defined
  [100%] Linking CXX executable linux_wsl_test
  mipsel-openwrt-linux-g++: warning: environment variable 'STAGING_DIR' not defined
  mipsel-openwrt-linux-g++: warning: environment variable 'STAGING_DIR' not defined
  [100%] Built target linux_wsl_test
  </code></pre>
  
  <p>On a WSL shell:</p>
  
  <pre><code>max@DESKTOP-ISH7UJQ:~/build_dir$ /usr/bin/cmake --build /mnt/c/Users/Maxi/CLionProjects/linux_wsl_test/cmake-build-debug-wsl_omega --target all -- -j 2
  [ 50%] Building CXX object CMakeFiles/linux_wsl_test.dir/main.cpp.o
  [100%] Linking CXX executable linux_wsl_test
  [100%] Built target linux_wsl_test
  </code></pre>
  
  <p>What's going on here?</p>