Cách fix lỗi heroku login trong CLI không hoạt động trên ubuntu/window (Fix heroku login command not working)

Đây là ảnh của lỗi:

1

Nghĩa là khi bạn dùng lệnh heroku login thì con trỏ cứ nhấp nháy hoài mà không hiển thị Email và Password cho bạn nhập. Và bạn không thể thực hiện heroku apps, heroku app:destroy,…..

Nguyên nhân lỗi là do file thông tin đăng nhập gặp vấn đề gì đó. Bạn chỉ cần xóa (lệnh mv trong linux) là xong.

Nên cập nhật heroku heroku update trước khi thực hiện sửa lỗi.

mv ~/.netrc ~/.netrc.backup
heroku login

Trên Window, các bạn tìm file _netrc.  (tìm thư mục cấu hình hoặc dùng tính năng search trên window) và xóa nó đi.

Sau khi xóa file đó là heroku login bình thường:

1

Một vài lưu ý nhỏ:

Sau khi login và thực hiện xong công việc, các bạn nên sử dụng lệnh heroku logout để đăng xuất khỏi phiên làm việc, như vậy sẽ ít xảy ra lỗi hơn.

Tham khảo thêm tại: https://devcenter.heroku.com/articles/heroku-cli#homebrew-specific-issues

Nguyên văn:

Troubleshooting

If you’re having issues with the CLI, first ensure that you’re using the latest version. If you’re not, try updating with heroku update.

Not all methods of installation support heroku update.

  • If you installed the CLI with apt, you need to use sudo apt-get update && sudo apt-get upgrade heroku instead.
  • If you installed the CLI with npm or yarn, you need to use npm upgrade -g heroku-cli or yarn global upgrade heroku-cli instead.

If the CLI fails to update, try uninstalling it with the instructions below, then reinstalling it. Ensure that you don’t have the legacy Heroku Toolbelt or Heroku Ruby gem installed by using which heroku or where heroku (on Windows) to confirm what the heroku command points to. You might need to modify your PATH to include /usr/local/bin/heroku (for most installations).

If you’re still encountering an issue, you can set the following debugging environment variables to help diagnose it:

Environment Variable Description
HEROKU_DEBUG=1 Shows debugging information mostly related to Heroku API interactions
HEROKU_DEBUG=2 Same as above but adds HTTP headers (only for “v6” commands)
HEROKU_DEBUG_HEADERS=1 Alongside HEROKU_DEBUG=1, shows HTTP headers
DEBUG=* Shows very verbose debugging information

You can also check the CLI’s error logfile, which is stored at one of the following locations depending on your operating system:

OS Location
MacOS ~/Library/Caches/heroku/error.log
Windows %LOCALAPPDATA%\heroku\error.log
Linux/Other ~/.cache/heroku/error.log (or XDG_CACHE_HOME if set)

If you continue to have problems and the CLI is up to date, or if updating fails for other reasons, you can reset the CLI by deleting its user directories. These directories are replaced automatically and you will not be logged out, but you will lose any installed plugins.

First, run heroku plugins to list your installed plugins so you can make sure to reinstall them.

Then, delete the following directories:

Windows:

  • %LOCALAPPDATA%\heroku

MacOS/Linux/Other:

  • ~/.local/share/heroku (or XDG_DATA_HOME if set)
  • Either ~/Library/Caches/heroku on MacOS, or ~/.cache/heroku on Linux/Other (or XDG_CACHE_HOME if set)
  • ~/.config/heroku(or XDG_CONFIG_HOME if set)

Login issues

If you are experiencing issues with logging in, try moving your .netrc file. This is where the CLI stores credentials:

mv ~/.netrc ~/.netrc.backup
heroku login

On Windows, the file is named _netrc.

 

Bình luận