Installing Heroku Toolbelt on Windows 10 - bash

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" $#'

Related

Installed Heroku but not recognised

I installed git and Heroku on my Windows8.1 64bit machine. On running:heroku --version I get the following error:
bash: heroku: command not found
What must I do to enable it?
Installing Heroku Toolbelt on Windows 10
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%"

How to understand PATH vs $PATH$ on different command line interfaces

I ran the command heroku version on my Windows CLI, and it returned the version of Heroku I have.
But when I do the same on my Windows Gitbash CLI, it says:
Doesha#Bub-PC MINGW32 ~
$ heroku version
/c/Program Files/Heroku/bin/heroku: line 4: /c/Program Files/Heroku/ruby-1.9.3/bin/ruby: No such file or directory
When I look at my path variables using the PATH command on my Windows CLI, my path looks like this:
C:\Users\Doesha>PATH
PATH=C:\Program Files\ImageMagick-6.9.2-Q16;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;
When I look at my path variables using the $PATH$ command on my Windows Gitbash CLI, my path looks like this:
Doesha#Bub-PC MINGW32 ~
$ $PATH$
bash: /c/Users/Doesha/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin:/mingw32/bin:/usr/bin:/c/Users/Doesha/bin:/c/Program Files/ImageMagick-6.9.2-Q16:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32:
Can someone tell me why my paths for both CLI's look different? (For example C:\Program Files\ImageMagick-6.9.2-Q16; and /c/Program Files/ImageMagick-6.9.2-Q16: look different).
Does each CLI have it's own set of path variables?
If so, how can I set up Heroku so that it can be added to my Windows Gitbash CLI path variables also?
The PATH will be different in an msys2 Git bash session since / represent where git is installed (with /etc/, /usr/, ... being the subfolder you see in your Git installation folder).
(see also "How are msys, msys2, and msysgit related to each other?")
Check that the /c/Program Files/Heroku/ruby-1.9.3/bin/ruby knowing that it is case sensitive in the bash session (it is not in a CMD Windows session).

Stardog Command not found

I am trying to get to install stardog on mac 10.8.5 using the instructions provided at http://docs.stardog.com/quick-start/.
The export path particular directory has been created and for which echo’ed to make sure that environmental variable is set up. The license key that is provided is also in the correct directory. When I try to run “$ ./stardog-admin server start” the command is not recognized. So I tried to create an export PATH to stardog’s bin, which did not work either.
I have also tried manually adding the path in the following:
- ~/.bash_profile
- ~/.profile
Still no luck, any ideas?
Using zsh I had a similar problem. For some reason, the docs suggest that from the stardog-directory-name directory you can run the command, but it didn't work until you cd into the bin directory. Once there ./stardog-admin server start should run correctly.
It sounds like you simply have something incorrect in your .bash_profile or .profile. If you run either of the stardog scripts from it's bin directory, it will work. If you're getting a command not recognized error, that sounds like bash cannot find the stardog-admin script.

Unable to run git from command line

I have installed GIT for Windows right now. And when I am running this into my symfony project to reinstall the vendors by
php bin/vendors install --reinstall
Then i am getting an error
git' is not recognized as internal or external command
I have set the environmental variables also as
c:/programme files/git/cmd
Now what should I do?
I have tried also for environmental variables
c:/program files/git/bin
but I am getting the same error
Two possible solutions:
My PATH has backslashes instead of forward ones.
your first line contains a typo, should be c:\program files\git\cmd
One more: If your path includes spaces, enclose it in quotes:
set PATH=%PATH%;"C:\Program Files\Git\cmd"
During Git installation, in the path environment settings chose the following one.
Even I had the same problem, of git not executed on my normal Command Line, but i just reinstalled it with the setting "Run Git from the Windows Command Prompt"
Just open cmd and run this command:
set PATH=%PATH%;"C:\Program Files\Git\cmd"

msysgit error with hooks: "git error: cannot spawn .git/hooks/post-commit: No such file or directory"

I'm having trouble getting post-recieve and post-commit hooks to work correctly with msysgit (Windows 7 Pro/32 and Ultimate/64). For post-commit hook I get the above error if I commit from either git-bash or the console, but it works fine if I commit through git-gui. For a post-recieve hook, all three give the same error.
I'm thinking this is some sort of permission or path error, but don't really have any clue where to start here.
Add the SHEBANG to the first line of hook, like so:
#!/bin/sh
echo "executing post-commit"
exit 0
This had me stumped for a while as well and I saw that adding the shebang fixed it. In SVN world, while in *nix we have a "pre-commit" script and in Windows we had "pre-commit.bat" and SVN automatically picked up the bat file in Windows. Git doesn't seem to pick up a pre-commit.bat ( or any hook ) and adding the shebang to the hook file worked.
I'm using SourceTree and git LFS and had a similar issue: cannot spawn .git/hooks/pre-push.
The fix was to delete the pre-push file (opening it revealed it was badly corrupted) and restart SourceTree at which point it regenerates the pre-push file and everything is back to normal.
If you have the SHEBANG and it still fails, make sure you have <path_to_git>\bin set in your path environment variable.
You'll probably also have <path_to_git>\cmd if you installed it to work from the command-line.
This is an old question, but I've been fighting with this exact problem and this SO question popped up, so I thought it worth the effort to record what worked for me.
In short: I needed to run Apache as a regular user instead of Local System. This was on a legacy test VM I was playing with, so it was only running Windows XP, but it appears that at least on that platform (and possibly others), msysgit just doesn't work properly when running under the Local System account (presumably the root filesystem isn't mapped properly). As a result, no shebang line will work as git-http-backend simply can't execute any msysgit binaries (even with absolute Windows paths).
Switching Apache to run as a regular user account fixed this problem completely. Obviously you need to ensure that the user Apache is running as has permissions to read/write the git repositories, but beyond that, just make sure your shebang line is #!/bin/sh and everything should be copacetic.
Lastly, yeah, this is a big hammer. Ideally you'd be able to use something like suexec on Windows, but a quick googling doesn't indicate an obvious path forward, there. Of course, if anyone has any ideas, I'd be interested.
For now, this works for me, but it doesn't seem ideal.
Got this in a repo using LFS, got rid of it with git lfs update --force
If someone, like me run into a similar problem with accessing git repositories through apache, you should set the PATH in Apache config, like:
SetEnv PATH "c:/Program Files (x86)/Git/bin;"
Using tortoisegit and LFS, for me just had to remove the files inside of the .git/hooks folder.
If you are using Android studio, you can remove this error by un-check the checkbox "Run Git hooks":
For me, removing a comment line on front of the shebang line fixed the error. Oddly, the script ran fine from the shell, just errored out when run as a hook.

Resources