conflicting cygwin and windows path - windows

if my windows path looks like this:
c:\ruby\bin;c:\cygwin\bin
then when i go into cgywin and enter "ruby" it will execute the ruby from c:\ruby\bin, failing to find the ruby installed in my cygwin. I have to exclude that path so cygwin would execute the one from /usr/bin.
But i need those 2 paths, since i want to run ruby in windows too.
Anyway to have cygwin have its own path and not inherit those in windows?
thanks.

Add an entry into your .profile to set the path to whatever you want it to be in cygwin.
In cygwin run the command:
$ <favourite text editor eg vi> ~/.profile
Then set the PATH environment variable to whatever you want it to be e.g.:
export PATH=/cygdrive/c/cygwin/bin
NOTE I can't remember whether you can use the c:... version of the path, but if you issue the env command you will see what it should be.

Related

permanently add binary to path on mac os

I am trying to permanently add a binary to the path variable on mac os. I have read several posts and blogs, it just does not work.
The question: given a directory /dir which contains an executable foo, how can I make it such that I can execute foo in the commandline without having to type export PATH... etc., and without having to move the foo executable to the bin folder?
I know there exists several scripts that are run on startup and whenever you open a command prompt, I just cannot seem to find the correct one. If I manually execute the export PATH... command and then do foo, it works.
If the export command works for you, just add it to either ~/.zshrc (on zsh) or ~/.bashrc (on bash).

How to override /usr/local/bin missing from bash profile

I'm trying to override a command that currently defaults to the executable in /usr/local/bin/ffmpeg. I thought I could do it by exporting a PATH to ffmpeg installed with homebrew above the one installed in /usr/local/bin, but when I edit ~/.bash_profile I cannot find the exported path /usr/local/bin. Yet, when I echo the PATH I see /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/ with the exported paths appended to it. Any idea how I can override commands in /usr/local/bin?
/home/user/.profile and other things actually included from global /etc/profile.d, /etc/bash.bashrc and so on, depending on your distributive. They are primary for your shell.
There is no defaults, Linux just searching first occurence of executable in your PATH, so just place directories in correct order in PATH:
Instead of:
PATH=$PATH:/mydirectory/bin
Use:
PATH=/mydirectory/bin:$PATH

Running Python27 interpreter in bash shell on win7

Added to ~/.bash_profile
PATH=c:/Python27:$PATH
and
env | grep PATH
shows the path c:/Python27
However I cannot run python interpreter from command line in bash. I'm on Windows 7 and I can run python from any directory in command prompt after doing
path %path%;C:\Python
Or adding the path to my Environment Variables
In bash I am able to do other commands from any directory in terminal after adding their path to ~/.bash_profile given the path is a sub-directory of ~/
If the path in .bash_profile is C:/ rather than ~/ it doesn't work. So my question is when adding a path to .bash_profile where the location is in C:/ rather than ~/ how do i do it?
Bash uses : as the path separator, so you actually just added "c" and "/Python27" to your PATH.
Different Windows GNU toolset ports have different ways of working around this. You can try ls /c/, ls /cygdrive/c or read your port's documentation to see how it handles this.
If you find that e.g. /c/Python27 is mapped to c:\Python27, then you can add that to your path instead.

How do you set java version in windows git bash?

How do you set the java version to use in a windows git bash? Does it work via the environment variables? Java -version gives another version in dos command prompt than in git bash...
Let's say you want to try other Java versions but you don't want to alter the Windows environment variables.
Steps:
Go to your home folder. i.e. C:\Users\MyAccountName
Edit the .bashrc file and add the following code below.
#For example:
export JAVA_HOME='/c/Program Files (x86)/Java/jdk1.8.0_45'
export PATH=$JAVA_HOME/bin:$PATH
.bashrc and .bash_profile are files created during the git-bash installation.
You don't set the java version. You are seeking the $PATH (bash) and the %PATH% (Windows/DOS/cmd.exe) environment variables. When you run the command java -version, the shell searches the directories on the $PATH to locate the java program and run it with the given arguments. If you get different results in different shells then that means you have different PATHs such that a different installation of Java is found.
Go to System Properties -> Advanced -> Environment Variables
New System Variable
'Variable name': PATH
'Variable value': C\Program Files\Java\jdk-9\bin (or whatever your path is)
Restart Git Bash
(Windows 10)
Yes the environment variables affect which java is used in Git Bash. But if setting the $JAVA_HOME and $PATH variables doesn't seem work, try this:
Go to the folder where Git Bash is installed (usually C:\Program Files\Git)
Go to usr/bin folder, i.e. C:\Program Files\Git\usr\bin
There should be a file named "java" there. Rename it to "notjava".
Now set the PATH variable as described in the other answers. I.e.
export JAVA_HOME='{yourjavahome}'
Restart Git Bash.
This is what worked for me. I'm using Git for Windows v2.17.0.
Go the location where you want to set java path temporarily. Run below command.
export PATH="/c/Program Files/Java/jdk-11.0.1/bin:$PATH"
User the jdk version you want in place of jdk-11.0.1

Where do I put mxmlc so that I could just type 'mxmlc' in the terminal to compile a swf file?

I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
You need to modify your "$PATH" environment variable, so that the tool is in that directory. However, if you want to make this very easy... you can download my macosx-environment-setup.tar.bz2 program. If you execute the "install.sh" script using "sudo ./install.sh", it will setup your environment in such a way that if you use "/Library/Flex4SDK" as the location for the Flex4SDK, it will automatically find it, define FLEX_HOME to point to that location, and it will also ensure that the binaries from the Flex4SDK are in your PATH.
Side Note: This is up on the web, because I use it in my Development Environment Setup How-To Guides. If you aren't too keen about running "sudo ./install.sh", you need to choose a location (I am going to assume "/Library/Flex4SDK", so that the tools are located in "/Library/Flex4SDK/bin"), and then you would simply need to edit your "~/.profile" file (using "nano ~/.profile"), adding the following to the very end:
export FLEX_HOME=/Library/Flex4SDK
export PATH="$PATH":"$FLEX_HOME/bin"
Note that these changes occur in your shell... they will not affect programs that are launched by double-clicking them in Finder. In order to affect those programs, you will need to place the environment variables in a file named ~/.MacOSX/environment.plist. See Automatically build ~/.MacOSX/environment.plist for a script that will automatically generate such a file using the current environment variables defined in your shell.
There are a few ways to answer this:
In one of your directories searched
by PATH (see the list with echo
$PATH)
Add a new directory to PATH
(e.g. in your ~/.bashrc
export PATH=$PATH:/path/to/bindir)
Add an
alias to your program (e.g. in your
~/.bashrc alias
mxmic=/path/to/mxmic)
(I'm assuming you're using bash shell, which is usually the case you can check with echo $SHELL)

Resources