Heroku CLI commands 'pico' not recognized on Windows 10? - heroku

I am using the Heroku CLI in order to edit my MySQL ClearDB Server on it. Whenever I carry out the command
heroku config:edit --app myApplication
I get an error referencing ‘pico’ command.
This is what it is in it’s entirety:
Fetching config... done
Waiting for pico... 'pico' is not recognized as an internal or external command,
operable program or batch file.
Error: spawn pico ENOENT
at notFoundError (C:/Program Files/heroku/client/node_modules/cross-spawn/lib/enoent.js:6:26)
at verifyENOENT (C:/Program Files/heroku/client/node_modules/cross-spawn/lib/enoent.js:40:16)
at ChildProcess.cp.emit (C:/Program Files/heroku/client/node_modules/cross-spawn/lib/enoent.js:27:25)
Since I am using Windows 10, I can't directly obtain 'pico' which is for Unix systems. Don't know if there's a way around this, perhaps there is some alternative command prompt simulator I could use although don’t wanna go that route; or more favorably method of making it work by changing the default text editor for the CLI?

Doesn't fix the 'pico' problem but
heroku config --json --app my_app
will list your config variables to the terminal. These can then be modified using the
heroku config:set config_Key=config_Value --app my_app

Related

Heroku: heroku is not recognized as an internal or external command, operable program or batch file

As you can probably tell by the title, I am having difficulty with Heroku. Whenever I run heroku --version in the Command Line, I receive the error 'heroku' is not recognized as an internal or external command, operable program or batch file. I have tried uninstalling and re-installing heroku multiple times, to no success. I have included screenshots of the download steps which I took.
Specs:
Windows v10.0.18363.1198, 64-bit
heroku CLI v7.47.3
Git v2.29.2.windows.2
Download Steps:
Make sure that you add the path to heroku to PATH. In this case it would be C:\Program Files (x86)\heroku\client\bin
Make sure you restart your system and run your command again, worked for me earlier.
After the restart, check your Heroku version use heroku -v in terminal or CMD.

What could be the reason why "heroku open" command is not working?

I have successfully deployed a django app on heroku using this guide. The heroku cli is installed as a snap application on my system - I'm running Fedora 32 on a Dell xps 15 - and everything seems to be working fine except when I try to run the app locally.
When I attempt to run the app locally, I get the following error:
$ heroku open
▸ Error opening web browser.
▸ Error: Exited with code 4
▸
▸ Manually visit https://[myapp].herokuapp.com/ in your browser.
I tried variations of the command to no avail:
$ heroku open -a [myapp]
$ heroku open -r https://git.heroku.com/[myapp].git
When, instead, I run it with heroku local it runs without any problems.
I look at the logs but couldn't find any clues. Neither was I able to find any useful information.
What am I missing?
Try setting the browser in your ~/.bashrc using export BROWSER=
If someone uses Windows Subsystem for Linux, set the BROWSER environment variable in the corresponding shell configuration file (e.g., ~/.zshrc) to wslview.
export BROWSER=wslview

Push From Git Bash to Heroku

I want to push a project I created to Heroku from Git. I'm running windows and have the Git Bash shell installed as well as the Heroku CLI. Running this from Git Bash shows my Git version:
$ git --version
git version 2.14.1.windows.1
However, when I try from that same Git Bash shell to create my application on Heroku as a remote Git repo, I get an error:
$ heroku create
bash: heroku: command not found
So instead I created my application on Heroku from a regular windows cmd terminal and that worked (i.e., when I log into heroku I see the remote repo). But when I try to do a git push from the windows cmd terminal it does not recognize git:
C:\myapp>git push heroku master
'git' is not recognized as an internal or external command,
operable program or batch file.
Whereas when I try to do a git push from the git bash shell, I get this error indicating perhaps it doesn't know what to make of heroku:
$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
So it seems my regular windows cmd terminal recognizes heroku, but my Git bash terminal does not. How do I configure Git bash to recognize the Heroku command?
Note: When I do a env | grep path from the Git bash shell the results do include my C:/Program Files/Heroku/bin directory, so Git is aware of my Heroku path.
Your problem is not that git would not push to heroku, but that you actually haven't installed git on your system, as the message you posted suggests.
'git' is not recognized as an internal or external command,
operable program or batch file.
At heroku's documentation there is a whole article about pushing to git, if you experience further problems after installing git, you might find a solution there.
Found a solution! It required the following 3 steps/considerations:
First, I followed john g's answer here, which is to close Git Bash and login to Heroku via a windows cmd terminal, then use Git Bash as per normal.
Second, when issuing a heroku command from Git Bash on Windows, include the extension, as described here. I.e., issue heroku.cmd create (instead of just heroku create).
Third, apparently the git push heroku master command must be issued from the same Git Bash terminal where you just issued heroku.cmd create. When I had issued it from a separate terminal I got an error saying "'heroku' does not appear to be a git repository".
I'm posting this, in hopes that it may help others and save them the same trouble I had. This was driving me mad and I tried every solution I could manage to find on the issue. Spent several hours trying to trouble-shoot it. What it actually ended up being was a conflict with my internet security, specifically Comodo Internet Security Premium 10. I received no warning, it just automatically added it to a blocked list on first execution. If you are running internet security software, especially on a Windows machine, this very well could be your issue. Remove the command file found at C:\Users\YOUR_USER_NAME\AppData\Local\heroku\client\bin\heroku.cmd from any block list, as well as any other executables from heroku that may be on the list.

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

Setup heroku environment on different machine

I have two laptops, one work laptop and another personal laptop. I have setup the Heroku environment on the work laptop. In git repo I have added github as origin and heroku as separate remote. Whenever I need to deploy anything I just use heroku remote to push my changes.
Now I have already cloned my code from github and also installed heroku-toolbelt on the second laptop. Now I want to push my code and access Postgres database from second laptop. But not sure how to do it. I am able to see the app config parameter by this command.
heroku config --app <MY-APP-NAME>
But when I try to access database I am not able to do so. The pg sub-command doesn't provide --app option to specify the app name.
I tried to look into heroku fork but this command will basically create another app from an existing app. I don't want to do this.
I also looked into herku git:clone but this command will basically clone the repo. I have already cloned my repo from githu.
I am not sure how to have the same heroku enviornment as I have on my work laptop.
EDIT1
I executed the following command to add heroku remote in git config.
heroku git:remote -a <MY-APP-NAME>
So I don't need to specify the --app option to access the config. It automatically picks the right config. But I when I try to access the Postgres database it gives me following error.
>heroku pg:psql
---> Connecting to DATABASE_URL
sh: psql: command not found
This exact same command works on another laptop.
EDIT2
I figured out the problem. Actually heroku is trying to run psql on my local box but psql was not installed on my machine and hence it couldn't successfully connect to remote database. So I executed the following command to install psql and it worked like charm.
brew install postgres
First add the git remote by executing the following line.
heroku git:remote -a <MY-APP-NAME>
Then make sure your system has the postgres client installed. If it is not installed then installed it using the following command.
brew install postgres
The above command is only valid for Mac which has brew installed. You can search internet to find the specific command for your own platform.

Resources