why does `brew uninstall --cask miniconda` require my password? - homebrew

I'm using Homebrew on macOS with M1 pro, in a non-admin standard user account. (I also have access to an admin account, but I deliberately created a standard account to mess around with Brew).
I installed brew by simply untarring the git repo into my homedir. I also installed miniconda without a problem with brew install --cask miniconda. At no point was I asked for my password.
However, now I'm trying to brew uninstall --cask miniconda, and it asked for my password. What the heck? Why?
And to make things worse, after I typed in my password, it said I'm "is not in the sudoers file. This incident will be reported."
Full output:
david-dev#Davids-MBP ~ % brew uninstall --cask miniconda
==> Uninstalling Cask miniconda
==> Removing files:
/Users/david-dev/homebrew/Caskroom/miniconda/base
Password:
david-dev is not in the sudoers file. This incident will be reported.
What makes this more confusing is that /Users/david-dev/homebrew/Caskroom/miniconda/base was created by me using brew install, and thus owned by me, so why is it asking for my password? I thought the whole philosophy of brew is to not ask for the password except for in the very beginning if I decide to go with the default prefix (in this case I did not). Is it simply because I didn't go with the default password that it exhibited this strange behavior?

Related

Troubleshooting "Permission denied # rb_sysopen" when attempting to install an earlier version of Rails

Summarizing my problem
Details about my goal:
I want to install an older(stable) version of Rails; specifically 5.2.5.
Describing the expected and actual results:
I expect my Mac running Big Sur v11.3.1 (apple m1) to install Rails successfully.
The actual result is (presumably) a permission/ownership based error:
$ gem install rails -v 5.2.5
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/ayylmao/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/concurrent-ruby-1.1.9/CHANGELOG.md
Obviously I see it's something to do with concurrent-ruby-1.1.9...though I continue to get this error with other gems throughout my efforts to install rails on this new-ish computer.
Describing what I've tried:
Both solutions here - no help
i've read this question - no help
I've read this question, but it's old
I've begun to explore my PATH:
/Users/ayylmao/.rbenv/shims:/Users/ayylmao/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
and I've uninstalled previous installations of Rails (and railties), as well as removed rbenv and re-installed (via the usual for me, Homebrew)
I've run brew doctor, i've updated gems with gem update, i've gotten rid of seemingly superfluous gems with for i in gem list --no-versions; do gem uninstall -aIx $i; done.
Obviously, i'm at my wits end here...
My best guess
looking at my $PATH it seems super "sus"...looks like there's some redundancy...but I'm not certain how to troubleshoot it or if that's the correct place to be looking.
I've dropped most details about my system and environment throughout my question, but here's an agregate:
MacOS BigSur 11.3.1 (perhaps something to do with Apple's SIP?) smh
zsh
homebrew
rbenv
ruby 2.7.2
stating my question without any ambiguity
How do I troubleshoot this error "Permission denied # rb_sysopen" via closer inspection of my $PATH? And is that the most likely culprit?
What steps would I need to take to go completely "nuclear"?
PS - full disclosure...yes I have used sudo in some instance of installing rails...though i've quickly uninstalled those versions shortly after installation. I apologize for the irresponsibility. I was not prepared for the Apple SIP and panicked months ago....Also, ZSH was a change for me as well.
It seems like your ruby installation through rbenv was made via sudo, which will create gem structure with root privileges.
So, when you perform a gem install rails from a regular user, you won't have the privileges to write into gems directory, raising the permission denied error.
You can confirm the permission by running:
ls -la /Users/ayylmao/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/
Try to reinstall your ruby with you own user (without sudo) and the installation of rails or other gems will sould be fine.

Homebrew error installing tomcat

After installing tomcat on Os x El Capitan using Homebrew I have received the following Warning:
your HOMEBREW_PREFIX is set to /usr/local but HOMEBREW_CELLAR is set
to /usr/local/Cellar. Your current HOMEBREW_CELLAR location will stop
you being able to use all the binary packages (bottles) Homebrew
provides. We recommend you move your HOMEBREW_CELLAR to
/usr/local/Cellar which will get you access to all bottles."
The command brew services list shows no services installed.
Printenv doesn't show any homebrew variable
It's not clear to me what should I do.
enter link description here
I also encountered this problem, in the end of the page to get accurate help,
brew bundle dump
rm -rf /usr/local/Homebrew/Cellar
brew bundle
I have received a similar warning when I tried to do a brew update.
It did not allow me to update. All I have done to resolve it was do a brew update in going to the /usr/local/Cellar directory.
From what I understand HOMEBREW_REPOSITORY path was modified or went missing when the OS was updated. After the brew update, the message said
Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
sudo chown root:wheel /usr/local
This got me back to my normal brew usage with out a problem.

Can't get Homebrew and git to work the way I want them to

First off, I'm sorry for any silly mistakes on my part. I'm just starting with OneMonthRails, and this is all very new to me. My problem is with Homebrew and git. I'm told that my problem has to do with environmental variables, and I've done enough research to be confident this is correct. Ok, here's the details:
I've tried to install Homebrew, but ran into a snag with Xcode being absent. Was running OSX 10.6.8, and had to upgrade to at least 10.7.x to install the latest Xcode. I upgraded to OSX 10.8.4 and installed Xcode and reran the following line
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
I get the following script:
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help
I am installing Homebrew so that I can install ImageMagick in order to run the Paperclip gem, so I take the advice of my Terminal about running $ brew doctor.
$ brew doctor
produces the line
Warning: Experimental support for using Xcode without the "Command Line Tools".
You have only installed Xcode. If stuff is not building, try installing the
"Command Line Tools" package provided by Apple.
Warning: Broken symlinks were found. Remove them with `brew prune`:
///long list of broken symlinks///
Warning: An outdated version of Git was detected in your PATH.
Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.
Please upgrade: brew upgrade git
I want to know what my git version is so I run the following script:
$ git --version
and that produces the following line:
git version 1.7.9.6
I identify where my git is located:
$ which git
and that brings:
/opt/sm/pkg/active/bin/git
After some more research, I find out that I can upgrade my git with the following script:
$ brew install git
The final line of the resulting script is a warning:
Warning: This keg was marked linked already, continuing anyway
==> Summary
🍺 /usr/local/Cellar/git/1.8.3.2: 1325 files, 28M, built in 45 seconds
I verify my git upgrade
$ git --version
git version 1.7.9.6
sudo think...maybe I need to run upgrade instead of install.
///restart computer///
$ brew upgrade git
Error: git-1.8.3.2 already installed
hmm... try doctor again
$ brew doctor
Warning: Experimental support for using Xcode without the "Command Line Tools".
You have only installed Xcode. If stuff is not building, try installing the
"Command Line Tools" package provided by Apple.
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
$ git --version
git version 1.8.3.2
YAY! I DID SOMETHING RIGHT! Now to finish with Homebrew so I can move on to installing ImageMagick:
$ brew doctor
Warning: Experimental support for using Xcode without the "Command Line Tools".
You have only installed Xcode. If stuff is not building, try installing the
"Command Line Tools" package provided by Apple.
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Arrg... I just installed Xcode. How do I install Command Line Tools? And what is this config Warning? I check it on StackOverflow, and it leads me here:
(.../questions/15225312/brew-doctor-gives-out-warnings)
I don't exactly know what I'm doing, so the following is kinda stupid
$ $PATH
nope
$ echo $PATH
nothing...
$ export PATH=/sm/pkg/active/bin/
nothing
$ export PATH= /sm/pkg/active/bin/
-bash: export: `/sm/pkg/active/bin/': not a valid identifier
(notice the space after the =)
I realize just how much I don't know what I'm doing, so I ask for help
$ brew help
-bash: brew: No such file or directory
uh oh...
$ brew doctor
-bash: brew: No such file or directory
I think I broke my computer, guys. What should I do??? I need to get Homebrew functioning so that I can install the ImageMagick image processor and use the Paperclip gem in Rails.
:((
I know it's super frustrating and some what confusing to get this all to work. Been there, done that.
There are a couple things at play here, so take them one at a time (in fact. I'm just guessing some stuff so I'm happy to update this answer as you let me know more)
Let's start with:
Warning: Experimental support for using Xcode without the "Command Line Tools". You have only installed Xcode. If stuff is not building, try installing the "Command Line Tools" package provided by Apple.
Installing command line tools is highly recommended. It's going to install gcc and other tools that help compile the code that homebrew downloads.
Open Xcode.
Open Preferences.
On the top bar, choose "Downloads"
Install "Command line tools"
Second, I'm not sure how you quite blew away your path. I would first see if you just messed up this terminal and if you close it and start a new terminal window if your PATH is okay.
However, failing that, here's a path that has some basic search paths that will help you get on your way:
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/usr/local/sbin
You should probably check your .zshrc/.zsh_profile or .bashrc/.bash_profile and see what you are setting your PATH to.
You won't want the space on either side of the = when you are typing that command.
I recently tried the upgrade from 10.6 to 10.8 (to install rails, bundler, RVM) and had lots of the same problems with brew and RVM conflicting AND having their own separate problems (PATH, permissions/non-writable folders, old versions XCode etc). It went off without problems after i tripled backed up everything (TMachine, git and manually copying selected directory trees) and did the clean Mountain Lion install off a USB drive.
If you're only having PATH problems, you could edit it manually/temporarily (until next time .bashrc is run, per comment to the answer: Brew doctor gives out warnings

Problems finding ruby, rails, git after bungled PostgreSQL install

I had rails working fine for several weeks but I tried to install PostgreSQL to match Heroku and it failed to work. Now, when I open the terminal it pretend rails is not there and sets the default ruby to 1.8.7. When I start RVM it finds the right version of ruby and finds rails again and can start the server but each time I open a new shell it's back to not finding anything. Plus, the git commands don't work even after starting rvm.
I have set rvm to start by default but that doesn't work either, it has to be started manually, and it still doesn't fix the git issue.
More Detail
I am installing on Mountain Lion. This already has Postgres but the tutorial I was using suggested installing fresh using Homebrew. The trouble was the Homebrew installation installs to /usr/local/var/postgres and the installed ppstgres installs to usr/var/postgres. The system automatically uses the usr/var/postgres version, so following the tutorial I chnaged the order of usr/local/bin and usr/bin in etc/paths. That didn't help so I changed it back. Everything then went to hell so I reinstalled Mountain Lion but nothing had changed.
There are two known problems with loading RVM & default ruby:
login shell: go to terminal emulator preferences and enable login shell, sometimes it might be required to use /bin/bash --login instead.
ZSH (+ Oh-My-ZSH): go to ~/.zshrc and comment out any lines starting with: PATH= or path=(, it is still possible to use those but they need to reference itself like: PATH=$PATH:HOME/.rvm/bin or path+=( $HOME/.rvm/bin ) - which update and not reset PATH. This might be a bug in terminal emulator or ZSH ...
The git issue is explained by the reinstall of Mountain Lion which did not automatically install the command line tools. That now works. The only pain is having to load rvm every time now.

Getting a "bad interpreter" error when using brew

I'm getting this error when I try to run any brew command.
Holger-Sindbaeks-MacBook-Air:~ holgersindbaek$ brew help
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory
I have absolutely no idea on how to fix this and been searching for a long time without answer.
I got this error (much the same):
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0
and fixed by the solution below:
Open brew.rb:
$ sudo vim /usr/local/Library/brew.rb
Change the first line's 1.8 to Current:
Before:
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
After:
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
Then brew works for me. Hope it helps if any other one got this issue. :)
If you get the error
Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew
change the MACOS check from <10.5 to <10.
Tip by #TimCastelijns:
10.5 doesn't work because in comparison, it's higher than 10.10 (.1 vs .5). I added a check (and MACOS_VERSION != 10.10) instead of lowering from 10.5 to 10.
What you are getting means that Homebrew has not been able to locate the Ruby interpretter at the specified location.
Install Apple Developer Kit (comes with Xcode) which should be available to you as an optional install (or you can simply download it from Apple). This will install the Ruby interpreter for you.
In case you already have Xcode installed, this means that one of these things is happening:
You have a broken Ruby installation
You have more than one Ruby installation
Your installation has not been configured properly.
To identify if this is the first case, you can run ruby and see if you get any response.
If you don't, your installation is broken and you need to reinstall it. If you do, you then run which ruby. This should give you the absolute path to your Ruby executable. If this is anything other than /usr/bin/ruby then homebrew (and a bunch of other programs) will not be able to find it.
In case you have not ever tampered with your Ruby installation, you can check to see if /usr/bin/ruby already exists or not: cat /usr/bin/ruby. If you get No such file or directory, then you can easily create a symbolic link to your Ruby installation. Assuming the output of which ruby to by /usr/local/bin/ruby, you create the symbolic link this way: sudo ln -s /usr/local/bin/ruby /usr/bin/ruby and all should be well.
If there is a file at that location, you can run file /usr/bin/ruby to see if it's a real file, a symbolic link, or a corrupted file. If it is a symbolic link, your installation should be working, and since it's not, it probably is either a corrupted symlink or it's a bogus file.
You can remedy that by first deleting it (sudo rm /usr/bin/ruby) and then creating a new symlink to the correct location (sudo ln -s /usr/local/bin/ruby /usr/bin/ruby).
If non of the above works, you should consult the homebrew team after a clean install of Xcode and removing any traces of a Ruby installation on your system.
EDIT
Alternatively, as pointed out by the other answers, the issue might be because of a bad ruby version in your Homebrew settings.
A quick fix might be updating your Homebrew:
cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master
If this does not help, you might want to get your hands dirty and manually fix the problem by:
Editing brew.rb from /user/local/Library/brew.rb
Changing /1.8/ to /Current/ in the first line, which will cause the hashbang to point to the current Ruby version as the executor
If this does not help, either, you can also modify the MACOS check and change it from 10.5 to 10 to avoid the infamous "Homebrew requires Leopard or higher" error.
DISCLAIMER
A bunch of thanks to other contributors in the answers below and their commenters. I am not committing plagiarism, simply aggregating the answers into one integrated article to help others.
Fix:
sudo gem install cocoapods
At the risk of oversimplifying things, try running
gem install bundler
I was transitioning my Ruby environment from RBENV to RVM and it worked for me.
This happened because I needed to update brew - in the updated version it already uses Current ruby
cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master
This solved the problem
You need to change the path for Ruby.Framework
I solved it with commands as mentioned.
brew install cocoapods --build-from-source
brew link --overwrite cocoapods
If you have a lower version below Xcode 11, you have to remove it before you use the above commands.
Reference: Ruby Framework issue
None of the above worked for me, so I kept browsing and found this answer,
https://stackoverflow.com/a/24225960/1359088
which did fix brew for me. He says in step 1 to install XCode 6 command line tools, but doesn't say how; use this command:
xcode-select --install
I got the same issue when updated to MacOSX High Sierra & using Xcode 9 with that. High Sierra update ruby gem to version 2.3 but xcpreety command of Xcode 9 still using Ruby 2.0 which is unable to find now & gives bad interpreter.
Just go to Terminal & run
sudo gem install xcpretty
Restart Xcode & do fresh clean build it works for me.
Hope it helps!!!
After upgrading to macOS High Sierra, get it fixed with following commands:
sudo gem install cocoapods
In my case seems like fastlane installed incorrectly with brew install fastlane system didn't write correct path to fastlane. I fixed it with alias fastlane=~/.fastlane/bin/fastlane
I solved it with commands as mentioned.
1.) Uninstall your GEM.
gem unistall GEM
2.) Then Install your GEM.
sudo gem install GEM -n /usr/local/bin
I got bad interpreter: No such file or directory error when used xcpretty and xcpretty-travis-formatter on upgraded MacOS.
To solve it
gem install xcpretty
gem install xcpretty-travis-formatter
That is why I can recommend you to reinstall failed component gem install <name>
#For example error looks like
/usr/local/bin/xcpretty-travis-formatter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
#use
gem install xcpretty-travis-formatter

Resources