Heroku error in Gitbash Windows 10 - ruby-on-rails

I cannot get Heroku to work in Gitbash on windows 10.
Gitbash version = 1.9.4.msysgit.2
Error Messages:
$ heroku version
/c/Program Files (x86)/heroku/bin/../client/bin/heroku.cmd:
line 1: #echo: command not found
/c/Program Files (x86)/heroku/bin/../client/bin/heroku.cmd:
line 2: setlocal: command not found
/c/Program Files (x86)/heroku/bin/../client/bin/heroku.cmd:
line 4: syntax error near unexpected token `('
/c/Program Files (x86)/heroku/bin/../client/bin/heroku.cmd:
line 4: `if not "%HEROKU_REDIRECTED%"=="1" if exist "%LOCALAPPDATA%\heroku\client\bin\heroku.cmd" ('
Any help is much appreciated!
Thank you,
Boba Fett
My Windows Environment Variables
The Error Messages in Gitbash

I was receiving the same error after I corrected the Path variable. What worked for me was installing a standalone version via bash. Uninstall the version of heroku that you have and then, in your shell, run the command curl https://cli-assets.heroku.com/install.sh | sh

Try using regular windows command prompt (cmd.exe) to test the heroku version heroku --version to confirm it is installed and also try to check where it is installed using the where heroku command

Related

Docker machine installation for windows

I just installed docker-machine for windows using the following command:
It created a bin folder with a docker-machine.exe file.
However after checking if it installed correctly with docker-machine version. I get the following error:
/c/Users/samta/bin/docker-machine: line 1: syntax error near unexpected token `<'
Fixed it I download the docker-machine.exe file for windows from github: https://github.com/docker/machine/releases/
and replaced the generated file from the command above.

Unable to find chrome binary in WSL while running Rails tests

I am trying to run integration tests for my Rails application in Windows Subsystem for Linux. I have downloaded the chromedriver file for windows from the official site and placed it in Documents/bin folder. I have added the following file in the same folder and saved it as chromedriver:
#!/bin/sh
chromedriver.exe "$#"
So presently Documents/bin folder has these two files: chromedriver.exe and chromedriver. I have added this folder to PATH in windows.
When I type chromedriver -v in Ubuntu terminal in Windows I get the following output:
ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770#{#1003})
But when I execute any Rails integration test I am getting the following error:
sh: 1: ["/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/opt/google/chrome"]: not found
sh: 1: ["/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/opt/google/chrome"]: not found
sh: 1: ["/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", "/opt/google/chrome"]: not found
Webdrivers::VersionError: Failed to find Chrome binary or its version.
chrome version in windows: Version 75.0.3770.90 (Official Build) (64-bit)
So linux is able to find chromedriver but not rails. How can I rectify this error? Should I run sudo apt-get install chromium chrome-driver? Or is there another method to make rails know the path to chromedriver binary?
You need to add the path to your chrome.exe to the PATH environment variable in Ubuntu

-bash: pg_dump: command not found

I'm trying to pull a production database locally for my rails app. My local postgres version was too low so I needed to update to Postgresql 9.6.5 from 9.4.1.
I installed Postgres 9.6.6 via Homebrew as such:
brew install postgresql#9.6
Then ran:
brew services start postgresql#9.6
However, when I try to do pg_dump I get -bash: pg_dump: command not found.
I also tried updating my path as such:
export PATH="/usr/local/Cellar/postgresql\#9.6/9.6.6/bin:$PATH"
Any idea what I need to do to get pg_dump to work?
Adding this to my ~/.bash_profile did the trick:
export PATH=/usr/local/Cellar/postgresql\#9.6/9.6.6/bin:$PATH
For those who have this issue on Mac even though Postgres path is correctly added on your .bash_profile I found that running pg_dump directly from the Terminal does the job.
Just open your Terminal and type:
pg_dump -U username your_database > db_dump.bak
I tried the ff approach and I got the same error:
sudo su - postgres
pg_dump -U username your_database > db_dump.bak
bash: pg_dump: command not found
If you installed PostgreSQL by pgadmin4 in Mac, you could find the pg tool in
/Library/PostgreSQL/{version}/bin/
Couldn't get path to work in Cygwin but could browse to my pg bin directory (C:\Program Files\PostgreSQL\9.6\bin) and run it directly from there.
For windows what worked for me is to add the Postgres to global vars from env, not ~/.bash_profile,
Go to Edit the system environment variables
Then Environement variables
Then Path then add the location of bin of postgres in my case C:\Program Files\PostgreSQL\14\bin\
Click ok on each open window
Close and reopen your visual code
Run your command
See Setting Windows PATH for Postgres tools for more details

Heroku toolbelt login with Cygwin hanging

I'm able to access Heroku with Cygwin with an alias, adding the following to my ~/.bashrc
alias heroku='heroku.bat'
This works, but when I try to use the $ heroku login command, it simply hangs forever.
I was able to work around this error using Windows Powershell, and barring a solution, will continue to do so while still on a Windows machine. Still, I would like to find out why this error occurs.
I'm using Windows 7 64-bit with Cygwin64.
I was able to get heroku working with cygwin on Windows 7 by installing the from the windows installer and setting ssh transport in my git config
http://www.railszilla.com/git-push-heroku-master-authentication/start
git config --global url.ssh://git#heroku.com/.insteadOf https://git.heroku.com/

Restarting daemon built in Ruby on Rails

I am trying to restart a daemon called site_checker.rb using SSH commands through PuTTY. This file is located in:
/home/MYUSERNAME/web/current/lib/daemons
After logging into my website, which is built with Ruby on Rails, I see the following on-screen:
[MYUSERNAME#MYUSERNAME ~]$
From here, I enter
[MYUSERNAME#MYUSERNAME ~]$ cd web
and then
[MYUSERNAME#MYUSERNAME ~/web]$ script/daemons start
However, I get an error:
-bash: script/daemons: No such file or directory
You try to start /home/MYUSERNAME/web/lib/daemons while you claim your script is actually in /home/MYUSERNAME/web/current/lib/daemons. You are missing the current.

Resources