Bash for Windows doesn't see environment variables - windows

I'm trying to setup my React-Native application under Bash for Windows. Everything was going fine so far but when I tried to launch react-native run-android, I got an error ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.. I checked PATH variable that bash sees by executing env|grep PATH and it's definitely not my Windows variable.
Is there a way to make Bash for Windows get environment variables from Windows? I believed that's a default behavior as tutorials (like this one) mention nothing about it.

Related

How do I execute a bash script once a specific anaconda environment is activated

I would like to for a bash script to run automatically once a specific anaconda environment is activated.
Is there a file that behaves like a bashrc for the enviroment?
I tried to look at the files in the /opt/anaconda3/envs/ENV_NAME/ folder, but I wans't able to locate a file that would be excetued every time an environment is activated.
Thank you!
E

ZSH Setup on Mac OS

Hi guys I have various problems with my ZSH shell. I installed Hyper Terminal for Mac and Oh My ZSH with a specific theme.
It works, however I have two problems:
1.) I have no internet connection, due to our corporate proxy. I tried almost everything. export http_proxy=http://my.proxy.dns:8080/ doesn't work and so on.
2.) I don't have the same environment variables as in my standard bash shell. For example when I run 'git' or 'npm' I always get zsh: command not found npm for example.
Now it seems I just need to apply my bash-config to my zsh shell.
I have for example tried setting: export PATH=$HOME/bin:/usr/local/bin:$PATH inside my .zshrc but no luck. Also source with my bashprofile doesnt seem to work.
How can I do that?

Configuring bash environment variables in VSCode

So far I've nearly got the setup I want for using GIT (Windows). All works fine from Git bash with SSH, Passphrases, the SSH config file and SSH-Agent.
But I can only communicate with any remote Repo's if I start Visual Studio from GitBash terminal by running "code"
This will be because the environment from the bash terminal is passed on to VSCode. I'm thinking I can get VSCode to do this without having to initiate it from the GitBash terminal if I can get the SSH-AGENT environment variables added to the VSCode environment somehow.
i.e. SSH_AUTH_SOCK and SSH_AGENT_PID.
Could there be a way to set these environment variables on startup of Code? This is assuming the SSH-Agent is already running with pre-defined values for those two variables. It's there, I just need to tell Code where to find it.
I've configured most of my setup as per:
http://letsdosql.blogspot.co.uk/2018/04/accessing-git-part-2-ssh.html
And with the ssh .config file:
https://developer.atlassian.com/blog/2016/04/different-ssh-keys-multiple-bitbucket-accounts/
Thanks in advance!
Ok. So the purpose of this was to open VSCode while being able to make use of SSH-Agent... without having to manually open up GitBash and start code from there. So all I've done is create a shortcut to a .sh script file which simply has "code" in it.
If I call the script via sh.exe, it still leaves a terminal window open while just referring to a .sh file directly does not. Also, now sessions of Code can access the SSH-Agent.
The only downside is if I start VCSode from a context menu it doesn't, but this works for me for now.

osx terminal syntax emulation on windows for node scripts

So I have a package json file that was built with osx in mind and it contains scripts for installs and builds. A lot of the scripts in that file have osx terminal specific syntax. Is there a way to emulate that terminal in windows so that syntax is read properly?
P.S. I've tried cygwin mintty (now called cygwin64 terminal), but still have the same issues.
EDIT My intention is not to maintain two files that essentially do the same thing and because we started off only using npm package manager I really don't want to introduce a task runner at this point.
EDIT 9/15/15
Here's an example of cygwin not emulating syntax:
NODE_ENV=production bin/build.sh in linux (ubuntu) will assign "production" to the node_env var and then execute the shell file build.sh, but in windows this syntax will cause errors with the var assignment and with the execution of the shell script file unless I use this syntax: setx NODE_ENV production&&bash bin/build.sh
OS X is based on BSD, so the closest approximation would be using a BSD VM.

MacPorts Installation -- Shell Commands/Postflight Script

I had run the MacPorts installer (2.0.3) for my OS X Leopard (10.5.8) which finished "successfully". Unfortunately the port command was not available so I looked in the MacPorts Guide which says that the installer should have run a so-called "postflight" script that sets the necessary environment variables. I tried to run the postflight script manually (which I downloaded from here), but the execution fails with the following output:
Detected the bash shell.
Your shell already has the right PATH environment variable for use with
MacPorts!
Your shell already has the right MANPATH environment variable for use with
MacPorts!
Your shell already has the right DISPLAY environment variable for use with
MacPorts!
Adding [default] tag to sources.conf if needed...
couldn't read file "/Contents/Resources/upgrade_sources_conf_default.tcl": no
such file or directory
Updating port image format...
couldn't read file "/Contents/Resources/images_to_archives.tcl": no such file or
directory
Synchronizing the MacPorts installation with the project's rsync server...
-bash: __PREFIX__/bin/port: No such file or directory
An attempt to synchronize your recent MacPorts installation with the project's
rsync server failed!
Please run 'sudo port -d selfupdate' manually to find out the cause of the
error.
You have succesfully installed the MacPorts system, launch a terminal and try it
out!
Read the port(1) manual page and http://guide.macports.org for help,
http://www.macports.org/contact.php if you need to get in touch with The
MacPorts Project.
Any ideas?
First invoke the port command directly:
$ /opt/local/bin/port help
If that comes back with something reasonable (like the help text) then it's just that your $PATH isn't being used by your current shell. Try logging off and back on again to resolve that in the short term (this will test that your .bashrc file is correctly configured) or you could just modify the PATH environment variable directly (which doesn't test .bashrc):
$ export PATH=$PATH:/opt/local/bin
You downloaded the postflight script but it alone cannot access the accessory scripts in Contents/ because those are located into the install package.
Those missing Tcl scripts are for upgrading from an older install, the log says PATH was already correctly configured but the macports bin directory could have the wrong position in PATH variables, for instance being at the end of PATH.
If you are doing a fresh install you can just only need PATH and MANPATH -you want man pages provided by macports before system's ones- as per [1]
[1] http://guide.macports.org/#installing.shell.postflight

Resources