Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/local/bin:/usr/bin: to the end of $PATH instead of at the top

Tags:

cygwin

I'm trying to ICU code using the MSVC linker. However, launching Cygwin places the /usr/local/bin and /usr/bin in front of the path, causing link.exe to always call the Cygwin version, instead of the MSVC version. How can I fix this configuration issue? Currently, I launch the VS command prompt, then launch cygwin.bat.

/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft F#/v4.0:/cygdr ive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c /Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Progra m Files (x86)/Microsoft Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86 )/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/F ramework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c /Program Files (x86)/Microsoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Prog ram Files (x86)/HTML Help Workshop:/cygdrive/c/Program Files (x86)/Microsoft Vis ual Studio 10.0/Team Tools/Performance Tools:/cygdrive/c/Program Files (x86)/Mic rosoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Mi crosoft SDKs/Windows/v7.0A/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c /Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygd rive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Progr am Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/Program Files (x86)/Microsoft ASP.NET/ASP.N ET Web Pages/v1.0:/cygdrive/c/Program Files/TortoiseHg:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/P rogram Files (x86)/nodejs:/cygdrive/c/Program Files (x86)/Common Files/Intuit/QB POSSDKRuntime:/cygdrive/c/Program Files (x86)/Git/cmd

ICU tells me to

Ensure that the order of the PATH is MSVC, Cygwin, and then other PATHs. The configure script needs certain tools in Cygwin (e.g. grep).

Update. My cygwin.bat looks like this:

@echo off

C: chdir C:\cygwin\bin

bash --login -i

Not very helpful.

like image 572
tofutim Avatar asked Feb 06 '12 23:02

tofutim


2 Answers

For a default installation of Cygwin, PATH is set is /etc/profile. You can modify PATH so that /usr/local/bin:/usr/bin are appended rather than prepended.

# PATH="/usr/local/bin:/usr/bin:${PATH}"
PATH="${PATH}:/usr/local/bin:/usr/bin/"

Resulting in:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>c:\cygwin\cygwin.bat

tim@xxx ~
$ printenv PATH
/cygdrive/c/Program Files (x86)/Microsoft F#/v4.0:/cygdrive/c/Program Files (x86
)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c/Program Files (x86)/Mic
rosoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft
Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studi
o 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cyg
drive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Mic
rosoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML Hel
p Workshop:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Team Too
ls/Performance Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0
A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.
0A/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cyg
drive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/
cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x8
6)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL S
erver/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn
:/cygdrive/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0:/cygdr
ive/c/Program Files/TortoiseHg:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin
:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/Program Files (x86)/nodej
s:/cygdrive/c/Program Files (x86)/Common Files/Intuit/QBPOSSDKRuntime:/cygdrive/
c/Program Files (x86)/Git/cmd:/usr/local/bin:/usr/bin/

tim@xxx ~
$ which link
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN/link
like image 86
tofutim Avatar answered Oct 12 '22 23:10

tofutim


I think that a cleaner method is to use the ORIGINAL_PATH variable that is created in Cygwin’s /etc/profile. Instead of modifying this file, modify your .bashrc file to use ORIGINAL_PATH and then append /usr/local/bin and /usr/bin.

.bashrc:

export PATH=$ORIGINAL_PATH:/usr/local/bin:/usr/bin

Then you don't have to modify the Cygwin installation files.

like image 22
Paul Avatar answered Oct 13 '22 01:10

Paul