Heroku CLI only works from root - heroku

I'm not sure why, but I can only run the Heroku CLI from root, not from a user.
When I run from user I get
>>heroku -v
and that's it. Nothing comes, nothing happens, it just freezes.
However when I open a new terminal window and change to root, it works fine
>>sudo su
Password:
>>heroku -v
heroku-cli/6.15.26 (darwin-x64) node-v9.6.1
>>
I have already tried uninstalling and reinstalling over and over again, I've used the Heroku direct download, as well as Homebrew, but I can't get it to work. I'm not really sure what I did to break my CLI, but how do I fix it? Where should I even look to see what the actual problem is?
UPDATES:
I've also changed shell types, and that did nothing to fix the issue either. The shell lists Terminal -- node /usr/local/bin/heroku -v at the top, if that helps.
As per the comments below, we tried copying the directory that the root user uses into my .local/share but this did not solve the problem either.
Further, I opened my activity monitor, and any time I try to run Heroku, it shows that node is taking up 95-100% of my CPU.

Spent nearly 12 days chatting with heroku staff. It turns out if your .netrc file is long (mine was 1.9 million lines), their parser has issues reading it.
Solution:
$ rm ~/.netrc
$ heroku login
Once the file is removed and you re-login it will create a new .netrc file without issues.
Why this happens:
My crontab uses an expect script to login to the blank environment. If you login over, and over and over, the .netrc file becomes huge.

Related

Can't log in to Heroku through CLI, after successfully logging in it won't let me enter any other commands

I'm using Windows 10 and Git Bash for my CLI. I have tried logging in through the default browser pop up as well as using $ heroku login -i to force a login using the CLI. Both have the same result, it says I have successfully logged in but the cursor just sits flashing under where it says I'm logged in and any command entered is ignored, it just advances to the next line.
CLI Window showing stuck cursor
I have made sure I am on the latest version of Git Bash (v2.34.1) and the heroku cli is also up to date (v7.59.2). I have also uninstalled and reinstalled Git Bash.
I did see a similar post where the same thing was happening to someone and they said they could login through the windows terminal and they were going to try uninstalling/reinstalling git bash but they never followed up with whether that worked or not (it didn't for me). I also was able to successfully login using the windows terminal but I'm just curious if there is a known fix for this issue so I can keep using git bash.

Mac OS terminal doesn't find commands

I have weird problem as all of the sudden terminal stopped reading any commands. Last weekend I installed Wordpress with PHP and mySQL and since that moment didn't have time to do anything more on laptop. Now I wanted to launch some react-native code but command wasn't found, then I tried different things to use some other commands and each time I get message
MBP-Mateusz-2:business-cards-native mateusz$ code .
-bash: code: command not found
and doesn't matter what command is that except standard ones like ls, cd etc. However when I try to write npm --version, or node --version, or launch visual studio code like before with code ., each time I get command not found. Doesn't anyone have issue like that? How to fix it as I'm super confused and have no idea even where to start.
You probably messed up your PATH environment variable, and now your computer cannot find the commands if you don't tell it directly where. The PATH variable contains the directories where the system should look for binaries if they're not in the current directory. If it gets corrupted for some reason, you won't be able to run any program from the terminal unless you pointed directly its location.
I would first run this command:
echo $PATH
so you can see which is the content of the PATH.
If it seems empty, or some critical folders are missing, try to add them temporarily:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Then try to run the commands again from the same terminal and see if that worked.
If that works, check if you have a ~/Library/LaunchAgents/environment.plist file and its content. It is possible that there is a key for the PATH and that its values are pointing something of your Wordpress stack but not the system directories.
If that looks fine, look at the ~/.bash_profile file. Find any export PATH instruction that may explain your issues. If you can't find any, but still exporting the PATH worked out, add at the end of the file that instruction as a workaround for fixing the mess:
export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
(notice that I'm ading $PATH in this last case so if there is any other path actually configured it is added as well)
Good luck.
EDIT: That's the usual issue people has, but now that I've read your comments, the issue seems a bit more serious. It looks like the mySQL setup destroyed your /usr/local/ folder, which means you lost all the binaries located there npm, code, etc.
If you have a backup of the whole filesystem (which by experience is unlikely), restore /usr/local folder.
If you don't have any backups, you can reconstruct /usr/local... by reinstalling the software that cannot be found. Reinstall npm, VSCode, etc, that will place their executables again in the /usr/local folders and from there you'll be good to go. Install brew (since it's likely that also got deleted) then try brew install node and see if now you can run npm. If that works out, I'm afraid you'll have to reinstall all the software you lost again.

I can't run any heroku cli commands - everything is completely unresponsive

I followed the directions to uninstall and then re-install Heroku here (homebrew instructions): https://devcenter.heroku.com/articles/heroku-cli
And now whenever I type heroku <anything> everything simply hangs. I can't ctrl+break out or anything. Oddly enough, I can close the iTerm window without a warning that a process is running.
Any help would be immensely appreciated. No idea what exactly to do about this.
I filed a ticket with Heroku yesterday about the same issue.
It turns out there is currently a bug in the .netrc parser. Try moving or removing the ~/.netrc file on your local machine and then log back in. This should resolve your issue.

Why sudo does not work in a macOS terminal?

I asked this question on mac rumors but as it's pretty developer specific no one could help so wondered if any developers here would know. Sometime in the last couple of weeks something happened that completely broke my sudo command. Now everytime I try to sudo anything it just comes up with a blank line. Nothing I can type into Terminal (or iTerm) does anything and I need to close the window.
I've got backups but don't know what files would have been broken and don't just want to reset my Mac to an arbitrary point in time and loose other work. I mostly just use sudo to edit /private/etc/hosts file and somehow now it's letting me edit and save that without sudo so I thought it might be stuck in sudo somehow but I've reset everything I can think of and haven't changed any settings that I know of.
I tried creating a new admin user and sudoing from that but it's the same.
I've tried following advice on various forums but none of them are working and I'm getting to the point I'm probably doing more damage to my mac. Anyone got any ideas of how to fix it or any files I can drag across from my backup that might fix it?
I've tried:
which sudo
and it comes up with /usr/bin/sudo which seems to be a valid file path.
After following this link - https://macperformanceguide.com/blog/2017/20170328_1326-macOS-10_12_4-sudo-broken.html - I found the solution and the problem. AMPPS had edited the sudoers file to include some NOPASSWD line which apparently doesn't work in 10.12.4. Commenting out those lines works
https://macperformanceguide.com/blog/2017/20170407_1157-macOS-10_12_4-sudo-broken-fix.html
Might be a good idea to compare your current /etc/sudoers with an old version just in case.
Also, keep in mind the expect file permission is:
chmod 0440 /etc/sudoers
I was also facing this issue for almost 3-4 months, It was bugging me a lot. It made me almost mad. Yesterday i decided to sit down and fix this issue once and for all.
After lot of reading and all, I found that AMPPS entry in sudoers file is culprit.
open sudoers file using sudo visudo command OR use some editor (take backup of sudoers file before making changes and also read guide to use "visodo" )
I commented 2 lines in my sudoers file and everything is fine now.
#%amit ALL= NOPASSWD: /Applications/AMPPS/Ampps.app
#%amit ALL= NOPASSWD: /Applications/AMPPS/ampps
Similar experience/solution has been shared by this blogger here,
You might not be having AMPPS on your machine so what worked for me, might not work for you.
Point to highlight is "There is something in there in your sudoers file which is causing issue, just find that line"

"No such file or directory - getcwd" error on rubygems on Mac Os Lion

I'm trying to launch a heroku console that uses rubygems but I keep getting this error:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:471:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:471:in `find_files'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:470:in `map'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:470:in `find_files'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1103
from /usr/bin/heroku:9:in `require'
from /usr/bin/heroku:9
I'm using Mac OS Lion 10.7.3. Any ideas on how to fix this? Thanks!
Maybe the current working directory of the shell that's used to start your heroku process doesn't exist (maybe removed by another process, as in my case), and therefore getcwd throws an error.
This happened to me. It turned out I had deleted the folder I was running the command in.
I had that same issue.... running sudo gem update --system fixed the problem... give it a try.
I had the same thing, just type cd in the terminal, then navigate back to where you were and it works.
Tried starting the rails server in another console tab.
cd . solved it for me
Faced a similar issue while setting up rails app locally.
The issue was that the server was running in a directory which i had removed from another terminal window to recreate the app.
Close terminal and do it again or go to some other directory and come back and do it...
Anything should work..It did for me.
I encounter a same one, it happened when the working directory has actually been removed.
This doesn't appear to be Heroku issue as something in your code is requiring this getcwd.
What happens if you run this application locally in production mode? Have you defined all of your dependencies for Heroku (either via a .gems file or Bundler)
In my case, I was in a directory that had "unusual" characters in its name: /Volumes/Members/Finance & Accounting/-MC 2008, 7848/2020.
And also, I was in a remote directory, as Mac users will recognize.
I simply did push ~ and ran the command again, then did popd to get back to my remote directory with odd characters in the name.
It could be that gem is ill-behaved in the face of directory names containing whitespace, or it could be that it doesn't work on networked directories.
The bash built-in pwd worked just fine in the remote directory with the funny name.
This whole thing makes me a bit nervous about gem.
solved for me
cd ..
cd -
you have to go back and return to current directory.
Ended up on this page from searching for the same error on AWS Elastic beanstalk.
The problem with getcwd is because EB is trying to repeat the deployment process endlessly. It changes the /var/app/staging directory before it is able to finish the current action. getcwd fails because the directory was already replaced. Try deploying a stable version or a sample app
This just happened to me while I was running a Sinatra app on my localhost and this is what I found.
Scenario:
I'm using Git as my version control and I switched branches from development to master to merge my branches. After the merge, with an active server running, I made a minor html change which shouldn't have blown up the app and when I went to check the change in my broswer my "request" came back with OP's error - just to note this app isn't deployed to heroku.
My guess:
I'm not familiar with the intricacies of Webbrick (or equivalent programs) but I'm guessing you had an active server running (like me) and it was was looking for specific file(s) in memory and when they were modified on a possible branch change or an important file was modified/deleted - Webbrick freaked out and didn't know where to find it/them and threw up this error.
I'm not sure what version control you're using but I know git is popular for heroku so I think this might have something to do with your issue.
Fixing the issue for myself was as simple as restarting the server, hope this helps future trouble shooters.
I solved this problem by closing and restarting my terminal, setting the correct Ruby version in the new Terminal to
$ rvm use 2.1.1
(or whatever Ruby version is relevant to your program)
as explained by gerardk
you could try this before launching back heroku console
$ pwd #ie: /mywork
$ cd ..
$ cd [pwd] #ie: cd mywork
now go launch back heroku console
Restart system fixed this problem in my case
I worked around this error by shutting down the server, restarting my terminal, then restarting the server.
sudo gem update --system (as Israfil Havilah mentioned) and rebooting the server (Ubuntu 16.04.6 LTS) helped me
Make sure, you are not switching git branches. To me, it happened due to switching between GIT branches deleted my folder.

Resources