Linking postgresql in homebrew - postgresql

I already installed postgresql, but it says I did not link to it.
I am running this in the command line and getting the following error:
myname#MacBook-Pro-8 ~> brew install postgresql
Warning: postgresql 10.4 is already installed, it's just not linked
You can use `brew link postgresql` to link this version.
myname#MacBook-Pro-8 ~> brew link postgresql
Linking /usr/local/Cellar/postgresql/10.4...
Error: Could not symlink share/man/man7/ABORT.7
/usr/local/share/man/man7 is not writable.
myname#MacBook-Pro-8 ~> sudo brew link postgresql
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.
I also tried:
brew prune; brew link postgresql
which gave me the same error:
Error: Could not symlink share/man/man7/ABORT.7
/usr/local/share/man/man7 is not writable.
Why is that folder not writable and what can I do to change that?

It was really painful solving this problem, so I figured I would leave it here for others to see.
Issue:
Homebrew install of Postgresql will not execute successfully. $ brew link postgresql results in failure due to directory not writable. New version of Homebrew will not allow sudo commands and System Integrity Protection prevents changing permissions.
Details:
I tried to use homebrew to install postgres and kept running into issues with syslink. When I ran $ brew link postgresql as homebrew suggested, I kept running into an error that it couldn't be completed because certain folders were not writable. I thought this would be easily remedied by running sudo but unfortunately the most current version of homebrew no longer allows the use of sudo commands due to security risks. My next thought was to my root user and use the macOS GUI interface to change the permissions on this folder because I am not sure how to do this on the terminal. Regardless of being logged in as 'root,' the OS would not let me change the permissions of the folder. I also attempted to use sudo and change the permissions in terminal and it did not work either. After several days of banging my head against the wall try all kinds of things to find a solution, I discovered that since El Capitan, macOS introduced System Integrity Protection aka 'SIP' or 'rootless.' As it turned out, once I disabled SIP, logged back into 'root' and changed my regular accounts permissions to Read/Write on the problem directories, I was able to go back to my regular account and successfully execute $ brew install postgresql.
(Assuming you currently have postgresql installed through homebrew but unable to link due a scenario like the one mentioned above, here is what I suggest to resolve your issue...)
Run $ brew link postgresql
Write down the directory path that the error says it is not able to write to. (e.g. usr/local/share/man/man7) NOTE: you'll want to actually write this down on paper or take a picture of the screen on your phone because you will not be able to use copy and paste)
Enable your 'root' user account if you have not already done so.
(instructions here) NOTE: make sure to make a really good password for this account and write it down somewhere safe. This is a powerful account and there's no way to recover the password.
Disable System Integrity Protection.
(instructions here)
Log into 'root' user account
In Finder menu bar select GO > GO TO FOLDER... (CMND + SHFT + G) and type in the path from Step 2.
Right-Click/ Cntrl-Click the folder and select Get Info
Click the plus sign at the bottom of Sharing & Permissions
Add your regular account to the list and change the permission to Read & Write
Go back to your regular account, run $ brew uninstall postgresql, then $ brew update and $ brew doctor . If those are all set run $ brew install postgresql.
You should be able to install without any problems now. However, if you run into a linking and permissions problem again, run $ brew link postgresql to figure out the problematic directory and repeat Steps 5 - 10 with whatever other directories are giving you trouble.
If everything is up and running properly. It is probably best to at least enable SIP again (instruction in the article linked in Step 4).
(To check that everything is working. I recommend running $ brew services start postgresql then $ createdb 'test' . In my case, it was when I originally tried to run createdb and got "command not found" that I realized something was wrong.)

Running this solves it. This gets around SIP.
sudo chown -R $(whoami) $(brew --prefix)/*
brew link postgresql

Related

Installing Scala Language on MacBook : Manually (No Brew or Coursier)

I am trying to install scala language on my work laptop (mac). Could someone let me know the installation commands if I am unable to use brew or coursier? I have downloaded the package from github directly but unsure of next steps.
When using courier download as given on scala website I get this error:
Checking if the standard Scala applications are installed:
Exception in thread "main" coursier.error.ResolutionError$CantDownloadModule: Error downloading io.get-coursier:apps:latest.release
I have a feeling that my works security does not allow this installation. Is there a way around it / manual install for scala?
Homebrew I cannot download as I am not allowed to give out passwords during installation.
You can try the command listed on their site for the Mac installation:
curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-apple-darwin.gz | gzip -d > cs && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup
This should do everything on its own.
However, if you have admin rights, I recommend installing it via brew. Using brew is the most popular and easiest way, and you will use brew a lot on the Mac:
brew update
brew install scala
If you are not allowed to have admin rights, go to your IT department and have them install Scala for you via the brew command.
If this is not possible, you can simply download the Scala binaries. For example, assuming you want Scala 2.13.10, just download and unzip the scala-2.13.10.tgz zip file at your desired location. After that, you will have to set up your PATH manually, to be able to use the scala command in the command line:
export PATH=”/Users/your_user/scala/bin:$PATH”
Here's a more detailed tutorial on this approach.

Can't use Watchman: "Operation not permitted"

Since updating Watchman recently (with Homebrew) I can no longer use it to watch projects. I get
{
"version": "2022.05.30.00",
"error": "std::__1::system_error: open: /Users/Path/To/Project: Operation not permitted"
}
I initially assumed that this must simply be file access issue I could resolve in the normal way, but giving the watchman app access to Files & Folders does not resolve the issue (even with termination of all watchman processes and restart of Terminal).
For good measure, I also manually added the watchman executable to Full Disk Access (something I've never needed to do before and am not comfortable with) but this also had no effect.
I have also terminated every relevant process I can think of, and even rebooted, twice. As far as I know the only change since Watchman worked was my running brew update watchman (which I have of course also uninstalled and reinstalled).
One concern is that for some reason I have multiple entries for watchmen in System Preferences, which weirdly results in it taking several dozen attempts to whack-a-mole all of them into a checked state for access:
How do I give Watchman the permissions needs to overcome this error?
Update Aug-19-2022
It looks like watchman: stable 2022.08.15.00 is working fine on my Mac M1. Upon start, you need to grant access to the local folders about to be synched.
Original
I also had the problem, like many others.
I reverted to a "working" version, e.g. 2022.05.16.00
There are multiple ways to do so; one (without private taps) would be:
Uninstall watchman
Downgrade the watchman.rb formula to an older version
https://github.com/Homebrew/homebrew-core/find/master
Navigate to watchman.rb
History -> select needed version -> View file -> Raw
Copy link to raw data
replace formula with that from raw version link
Install watchman according to that version
Pin it (to prevent further watchman updates)
Finally reset the watchman.rb formula to the original state again
# -- 1 -- uninstall
brew uninstall watchman
# -- 2 -- replace formula
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/8651d8e23d308e564414188509f864e40548f514/Formula/watchman.rb > /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb
# -- 3 -- install again, using replaced formula
brew install watchman
# -- 4 -- pin that version - Don't forget to unpin once this problem is solved...
brew pin watchman
# -- 5 -- reset formula to original
cd /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/
git checkout -- watchman.rb
Then shutdown any lingering instances of Watchman with
watchman shutdown-server
Remark: On Intel-Macs, homebrews repository is located at a different place. You can find out by calling brew --repository.
Typically, the Formula is expected in directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
Once the problems with watchman are solved, you can unpin watchman again and use the normal brew update/upgrade machanism.
On my M1 Mac:
My issue was that watchman didn't have permissions to ~/Documents folder. I don't know if this was the case before or after reinstalled it. Here are the steps I took:
brew uninstall watchman
brew install watchman
watchman shutdown-server (just in case it's running)
watchman watch-del-all
yarn start --reset-cache
When I tried to launch metro, MacOS prompted me to give permissions. After accepting, the bundler ran without issue.
It seems that the problem is that the watchman didn't have permission to access the ~/Documents folder. 🤔 Reinstalling watchmen seems to work as it triggers the grant access prompt.

How do I delete the Postgresql 13 installed by MacPorts?

I tried installing Postgresql 13 on my new computer using MacPorts and have been completely unsuccessful getting anything to run, and not even sure if it is actually completely or properly installed, and I would like to delete all the Postgresql installed by MacPorts on my system.
The only directories for Postgres I have found are:
/opt/local/include
/opt/local/lib
/opt/local/share
nothing in:
/Library
This doesn't seem like the installation locations I have read anything about and I haven't found anything about uninstalling this from my system.
So, the question is, what do I do?
Do I just delete those directories and move forward with a different installation method, or look in other locations, or just leave it there and try to install Postgresql another way?
sudo port installed
sudo port uninstall postgresql13-server
. . .

PostgreSQL reinstall : Failed to load sql modules into the database cluster

I tried to re-install postgresql 9.5.3-1 on my windows 7 without success. In fact, at each attempt, I have the message:
failed to load sql modules into the database cluster
then, I get the message:
Error running post install step. Installation may not complete correctly. Error reading C:/Program Files/PostgreSQL/9.5/data/postgresql.conf
I tried several attempts to solve this issue
change the installation folder
switch to 32-bit
reboot
clean the register before reinstalling
install as a postgres user as describe here (Failed to load sql modules into the database cluster during PostgreSQL Installation)
PS: installation language is French
I finally found a solution to my problem. I just installed postgres as a super administrator
Had same problem. Just double check permission for your data folder. I set full control to authenticated users and it installs correctly.
Same problem here.
In my case it was a backslash \ at the end of the password.
See also https://stackoverflow.com/a/32146553/2443630

Install oAuth PECL error: Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user

I'm trying to instal oAuth on OS X, but I am getting this error in the Terminal:
Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user
How do I allow it to be writable?
First find out where the php_dir is. You can do this by using the 'config-get' command:
pecl config-get php_dir
After this you can either:
Change the ownership of that folder (and any needed child folders)
sudo chown <username> <php_dir>
or
Set the php_dir to a different folder
pecl config-set php_dir /path/to/new/dir
The easiest way is probably to append sudo to the front of your install command.
See http://linux.about.com/od/commands/l/blcmdl8_sudo.htm to read more about the handy "super user" command.
For further references, on OS Catalina, due to write permission on /usr/bin - lib folders, you should move all config folders on pecl to some writable location (except php_bin which is php directory, this one should point to your php folder).
This is due to a feature in Mac OS called System Integrity Protection (SIP). SIP prevents the editing of critical system files and directories.
To get around SIP restrictions for the purposes of installing oAuth, you can disable it temporarily. Boot into recovery mode and run the command csrutil disable. After that, rebooting normally and attempt the install again.
After the install has been completed, re-enable SIP by booting back into recovery mode and running the command csrutil enable. Note: it's highly recommended that you re-enable SIP to protect your computer.