Adding gitbash to windows cmd to run make files - windows

i have a windows machine that i installed git on it . on install i checked the add the gitbash to environment but after install when i run a smiple command like ls in my windows cmd i get the error
'ls' is not recognized as an internal or external command,
operable program or batch file.
now this is my env variables on my windows
the second one was added by git automatically on install but I add the first one by searching on stack overflow but none of them seems to work .
Extra Details :
in case you want to know what trouble it cause me . i am running some make commands that works properly on my gitbash but on my goland terminal it gives this error
./scripts/fmt.sh provider
process_begin: CreateProcess(NULL, sh C:\Users\farsh\go\src\gojeh\scripts\fmt.sh provider, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:16: run] Error 2

TL;DR
Git for Windows deliberately only puts the bare minimum on your Windows PATH
Details
If you look at the git\bin directory, you'll see that only git, bash and sh are there. Then there's a git\usr\bin directory will the standard *nix-style utilities you're expecting, including ls, although not including make on my machine. Those are not added to your Windows path, because many of them would conflict with the standard Windows utilities, and shadowing them could have unpredictable effects on other stuff running in Windows.
So you'll find the extra stuff is only visible when you're running inside Git Bash itself, where they're expected to work the *nix way.
If you need make for your system, you should probably install a version intended to be used on Windows.

Related

How to change the command base in Git Bash in VS Code?

I'm learning to use Git. After installation I can open a Bash terminal on VS Code (I'm using Windows if that's relevant). Right after opening a Bash terminal, this command shows up automatically (the id and path are masked for privacy):
myid#machineid MINGW64 /c/Users/...
$ source C:/ProgramData/Anaconda3/Scripts/activate base
(base)
I guess it means it's using Anaconda to run the Git command. However, it appears many CMD commands that otherwise work normally in a Windows terminal don't work. For example, I can't create a new folder. This error comes up:
$ mkdir test
bash: /c/ProgramData/Anaconda3/Library/usr/bin/mkdir: Permission denied
(base)
Similarly, commands like ls or touch just don't work. But I find pwd works. I look at /c/ProgramData/Anaconda3/Library/usr/bin and see there are a bunch of CMD command exe files in there, such as mkdir.exe, rm.exe. I also look at the Git installation directory and find a folder with similar exe commands (C:\Program Files\Git\usr\bin)
On the other hand, I can still use Git commands. So this works (after manually creating the folder test):
$ git init
Initialized empty Git repository in C:/Users/.../test/.git/
(base)
Also, if I don't use VS Code, but use a Git CMD then everything works just fine.
So the question is how I can fix it? More specifically, how can I direct Git to use Git command base in VS Code instead of depending on Anaconda base? What it currently means to me is that if I uninstall Anaconda then Git may not work in VS Code at all.

Installing Heroku Toolbelt on Windows 10

I've been having some issues installing the Heroku toolbelt on Windows 10, 64-bit.
It's the first time I install Heroku. I downloaded it from https://toolbelt.heroku.com/windows.
After installing, I tried launching a new Git Bash and typing heroku login but what I got back was bash: heroku: command not found
Running the same command on Windows Powershell, what I got back was
'MYSQL' is not recognized as an internal or external command,
operable program or batch file.
'MYSQL' is not recognized as an internal or external command,
operable program or batch file.
Any suggestions? I thought that googling those lines would help, but I haven't found much.
I followed the recommendation from here, but now when typing heroku login on the Powershell, nothing happens. Nothing changes on the Git Bash.
I checked, and the Heroku folder was added to the PATH.
I thought I'd ask for some help before installing anything else.
Thank you!
bash: heroku: command not found
The error message is clear: Bash cannot find the heroku command, it's not on your PATH.
I checked, and the Heroku folder was added to the PATH.
It seems you didn't check it correctly.
Note that even if it looks correct in the PATH settings window,
Git Bash might have a different PATH configured.
To see the PATH in Git Bash, run:
echo $PATH
When debugging path issues,
it's best to first run heroku with the absolute path. For example if it's in C:\Program Files\Heroku\bin\heroku then you can run in Git Bash with:
/c/Program\ Files/Heroku/bin/heroku login
If this works (and it should),
then you can add it to PATH like this:
PATH="$PATH:/c/Program\ Files/Heroku/bin"
Note that Heroku will likely need other programs too on the PATH,
such as MySQL and Ruby.
Find their absolute paths,
and add there directories to PATH the same way as heroku itself in the above example.
If instead of Git Bash,
you want to work in CMD,
the procedure is the same,
but the syntax to print and set PATH is different:
echo %PATH%
set PATH="C:\Program Files\Heroku\bin;%PATH%"
In windows bash instead of this
PATH="$PATH:/c/Program\ Files/Heroku/bin"
use this
PATH="$PATH:/c/Program Files/Heroku/bin"
My working solution (for git-bash especially) is:
alias heroku='winpty `where heroku.cmd`'
stored in .bashrc in home user dir
and them
heroku
works as expected
If using bash from VSCode, I had to restart VSCode, after installing heroku. If not using VSCode, you probably need to restart your bash terminal, after installing heroku.
In Control Panel\All Control Panel Items\System (if you are using Windows), go to Advanced system settings, and there in Environment Variables, you'll find two lists, on the same window, viz. System variables, and User variables for your system. Make sure you add your path, viz. C:/Program Files/Heroku/bin, in both of these lists.
I know this is an old thread and just want to share my solution.
Edit .bashrc for git-bash
alias heroku='"C:\Program Files\Heroku\bin\heroku.cmd" $#'

Unable to create vagrant file (homestead.yaml) on windows

I'm gonna to use vagrant on my windows desktop to develop Laravel project. I have followed all the steps to do that. But it has been failed to create homestead.yaml using bash init.sh command.
Below is the error :
Fakhreddin#Lenovo-PC3 /cygdrive/d/laravel-vagrant/homestead
$ bash init.sh
cp: unwritable ‘/home/Fakhreddin/.homestead/Homestead.yaml’ (mode 0500, r-x------); try anyway?
I'm using Cygwin for simulating Unix terminal in the Windows.
(Copy of the comment I wrote above)
Never used Cygwin in my life, but what I would try is to run it as Administrator and re-try.
Otherwise, you may want to consider changing console client. For example, if you install Git, you should be able to use Unix commands via standard Windows console.
I would seriously point the fault at Cygwin, or its settings. I am a member of a team in which all of us run Homestead on Windows 7, with no problems at all. The difference is, we use native Windows command line.

svn version control authentication fails when run from emacs

I'm using on my desktop native windows emacs 24.2 configured to use cygwin bash.
When I run SVN from cygwin bash everything works fine. It remembers my authorization credentials and connects to a repository. But when I try to run any version-control command from within emacs I always get the following message:
svn: E170001: Unable to connect to a repository at URL
'https://address.to.repo' svn: E170001: OPTIONS of
'https://address.to.repo': authorization failed: Could not
authenticate to server: rejected Basic challenge
I tried also connect with PSVN interface which also ends up with the same error message. It is somehow strange that it does not work the same way from cygwin terminal and emacs. Any help on this would be appreciated.
Solved now. The problem was that Emacs NT cygwin integrated was still using windows HOME path instead of using cygwinized HOME directory.
I think the full answer should be something like this:
SVN depends on the HOME path to find its per user settings (as most unix programs).
In cygwin that varible has something like "/home/pablo".
"/home/pablo" is really translated "drive:\cygwin_dir\home\pablo"
Emacs-nt grabs its HOME from the windows environment so it is a different HOME than cygwin's
emac's vc-svn uses the wrong path to look for its settings.
So there are two solutions (maybe more):
Make emacs-nt use the cygwin's HOME (so thats what cygwinization means!! :O), you need setup-cygwin for this, but specially you need one script it depends on cygwin-mount. So emacs-nt can understand cygwin's path "style".
(not recomended) The other way around, which is what I did, make cygwin use the window's HOME through a soft cygwin link. ln -s /cygdrive/c/Users/pablo/Roaming/ /home/pablo
Make a soft link so the cygwin's subversion dir points to the windows one ln -s /cygdrive/c/users/pablo/AppData/Roaming/.subversion /home/pablo/.subversion
The second solution WILL lead to cygwin's ".bashrc" not executed. So environment variables and aliases defined there won't be define. I still think that it can be done, but I don't have the proper cygwin knowledge needed to tweak that solution. So right now I'm using the solution number 3.

cmd 'patch' is not recognised as an internal/external command, operable program or batch file

I'm trying to patch my wordpress installation to protect from user enumeration.
I found a patch - here
It said to use it I need to navigate to the sites root folder, add the patch file then run it using cmd , patch -p0 <wpuserEnum.patch
When I hit enter I get the 'patch' is not recognised as an internal/external command, operable program or batch file' message
Not the most helpful error reporting. I have googled the problem all day and have not found any solutions regarding 'patch' specifically
I have checked PATH and there is a C:\Windows\System32 path there
Can anybody shed any light on what is happening and why?
I am running Windows Server 2008.
patch is not part of Windows so it won't be installed unless you install it yourself. You can get it as part of the GnuWin32 project - http://gnuwin32.sourceforge.net/packages/patch.htm
You need to edit your system environment variables, then add the path to patch.exe(in GnuWin32\bin) to the PATH environment variable...after restarting the cmd, patch should be recognized...
It helped me to run the next command:
npm i patch-package
(From here: https://www.npmjs.com/package/patch-package )
I don't think GnuWin32 works for Win10 (at least they only mentioned Win7 in their website).
The safest way (works for me) is Git for Windows: https://git-scm.com/download/win
It has patch.exe in Git\usr\bin folder. Just add it to your path will work!

Resources