Advice on how to delete a software on OSX - macos

I have a software installed on my OSX computer that affects my daily work so I decide to remove it.
The OSX version is 10.14.3.
I have disabled System Integrity Protection (rootless).
It has a continuous running daemon set up in launchctl.
When I try to run the command "sudo launchctl remove "deamon'name"" to disable the running daemon, I got
sudo: unable to execute /bin/launchctl: Operation not permitted
Of course, remove the files for this software using "sudo rm -rf" failed with "Permission denied"
So how can I remove this software without reinstalling OS?

Related

Unable to install ClickHouse in MacOS due to CANNOT_OPEN_FILE

While trying to install ClickHouse in a macOS Catalina, doing the following command:
➜ ~ curl -O 'https://builds.clickhouse.tech/master/macos/clickhouse' && chmod a+x ./clickhouse
After trying to execute sudo ./clickhouse install it will complain with the following message:
Copying ClickHouse binary to /usr/bin/clickhouse.new
Code: 76. DB::ErrnoException: Cannot open file /usr/bin/clickhouse.new, errno: 1, strerror: Operation not permitted. (CANNOT_OPEN_FILE) (version 21.10.1.7886 (official build))
Why is it failing even if I sudo the command? Are there any other commands required before trying to install ClickHouse?
/usr/bin is protected by Apple's SIP (System Integrity Protection) mechanism. You can install clickhouse into specific (not protected) directory by passing --binary-path flag. This way you won't have to disable SIP.
For example, on MacOS you can install into /usr/local/bin, which is not protected, by using this command: sudo ./clickhouse install --binary-path /usr/local/bin/.
This is a rootless (SIP) mechanism that Apple has added to the new version of the system. The basic purpose of SIP is to prevent programs from obtaining root privileges and modifying several key system directories. It can indeed play a certain protective role.
The main directories to be protected are:
/System
/usr
/bin
/sbin and preinstalled apps
Close the SIp in the kernel:
Restart the computer and press command+R until the Apple logo appears. At this time, you will enter Recovery Mode.
After selecting a language, enter recovery mode, find Utilities in the above menu, and find Terminal in it;
Open the terminal and enter the following command to close SIP;
You can bypass the problem by installing ClickHouse this way here: https://clickhouse.com/docs/en/quick-start/#1-start-clickhouse.
Try to use docker to install clickhouse server/client.
docker pull yandex/clickhouse-server
docker pull yandex/clickhouse-client
docker run -it --rm --link some-clickhouse-server:clickhouse-server yandex/clickhouse-client --host clickhouse-server

Read-only file system" with SIP disabled in macOS Catalina

I am trying to copy some files from a path to my libs path (/usr/lib), I am trying with sudo cp {my file}/usr/lib/
bit I got this error.
/usr/lib/{my_file} Read-only file system
I have validated and indeed System Integrity Protection is disabled (SIP) I am using macOs Catalina 10.15.4
I Hope you can help me thanks.
You just should try with
sudo mount -uw /
it should work
I just recently joined stack overflow so I am not able to up-vote the above answer. Using sudo mount -uw / definitely works. In my case I needed to add a small script to /sbin to overcome an issue with VMware Tools. Starting with macOS Catalina, disabling SIP and then executing this command as root was the answer.
I'm also new to stack exchange, but want to add that
"sudo mount -uw /" worked. Thank you #Juanse
In my case, was suffering from the problem of Kernel_Task using more than 500% of CPU on my Mid-2012 15 MacBookPro aka (MacBookPro9,1 ) with quad-code Intel Core i7.
After multiple solutions did not work, I went on to try a solution posted at: https://discussions.apple.com/thread/8461404?answerId=33657338022#33657338022
Which instructed me to:
Reboot into recovery mode.
Select Utilities/Terminal, csrutil disable , reboot.
cd:
/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources
move or delete a file based on my version of Mac as listed in the thread. For my MacBookPro9,1 the file 4B7AC7E43945597E.plist
Reboot into recovery mode
Select Utilities/Terminal, csrutil enable , reboot.
The problem with the solution, is that when I tried to "mv 4B7AC7E43945597E.plist ~", or even "sudo mv 4B7AC7E43945597E.plist ~", I got a read-only file system message. Running "sudo mount -uw /" made the file system writeable. Note that the steps of booting into recovery mode and disabling / enabling csrutil turned off, and then back on the apple System Integrity Protection (SIP), which is necessary if you wish to change certain key system or configuration files.

VirtualBox install failed in a clean OSX 10.13

I did a clean install of High Sierra, Mac OS X 10.13 on my mac.
I've installed a few apps, some browsers, webStorm, vagrant, skype and slack.
When trying to install virtualBox I get an error message saying:
"The installation failed.
The installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance."
When checking the installers log file I get the following error mesage:
Oct 19 16:22:42 newens-mbp installd[519]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “VirtualBox.pkg”." UserInfo={NSFilePath=./postflight, NSURL=file://localhost/Volumes/VirtualBox/VirtualBox.pkg#VBoxKEXTs.pkg, PKInstallPackageIdentifier=org.virtualbox.pkg.vboxkexts, NSLocalizedDescription=An error occurred while running scripts from the package “VirtualBox.pkg”.} {
NSFilePath = "./postflight";
NSLocalizedDescription = "An error occurred while running scripts from the package \U201cVirtualBox.pkg\U201d.";
NSURL = "file://localhost/Volumes/VirtualBox/VirtualBox.pkg#VBoxKEXTs.pkg";
PKInstallPackageIdentifier = "org.virtualbox.pkg.vboxkexts";
}
I've googled this, and found a few threads here and there that solve different problems. But so far none has worked for me.
Some of the posts I've found:
https://www.virtualbox.org/ticket/15832
Error installing Virtualbox 5.1.10 on macOS Sierra, "The installation failed"
https://apple.stackexchange.com/questions/177868/virtualbox-4-3-26-on-osx-10-10-2-fails-to-install
Can't unload kext while installing VirtualBox 4.3.6
None of these solutions worked for me.
I don't have vmware installed, and have tried searching for the .match_kernel file to delete, but can't find it anywhere. I don't have the option of selecting a partition on disk utilities so can't do a repair disk permissions on it.
I've installed and uninstalled different versions and cold booted in between to try to see if that would help.
Thanks for any help!
after hours of hacking at this issue my coworker and i came to a workable solution. the issue (for me at least) was that when i went to install the package it was getting blocked. you can check to see if this is the case by attempting to install, and when it says 'install failed' go to your security & privacy (in system preferences) and go to the 'general' tab and near the bottom it will say that an oracle application was blocked.
here are the steps we came up with **NOTE: if you tried downloading or installing this a few times like i did you will want to first uninstall virtualbox using the virtualbox uninstall tool which you can find in the downloaded .dmg file. you will also want to eject virtualbox from your devices (in the left panel of finder). after that go ahead and follow these instructions:
Download VirtualBox 5.2 installer
Run the DMG, this creates a device
Attempt to install from .pkg file, it will fail at the validation step
Close installer and run the uninstaller.tool file. DO NOT DELETE THE INSTALLER DEVICE
Go to System Preferences -> Security and Privacy -> General and approve the blocked software from ‘Oracle America’
Run the install from the same .pkg file, it should now complete successfully
I finally managed to solve it with a suggestion from here: https://github.com/caskroom/homebrew-cask/issues/39369#issuecomment-339118861
Run this script:
#!/bin/bash
unload() {
if [ `ps -ef | grep -c VirtualBox$` -ne 0 ]
then
echo "VirtualBox still seems to be running. Please investigate!!"
exit 1;
elif [ `ps -ef | grep -c [V]ir` -gt 0 ]
then
echo "Stopping running processes before unloading Kernel Extensions"
ps -ef | grep [V]ir | awk '{print $2}' | xargs kill
fi
echo "Unloading Kernel Extensions"
kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
}
load() {
echo "Loading Kernel Extentions"
sudo kextload "/Library/Application Support/VirtualBox/VBoxDrv.kext" -r "/Library/Application Support/VirtualBox/"
sudo kextload "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" -r "/Library/Application Support/VirtualBox/"
sudo kextload "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" -r "/Library/Application Support/VirtualBox/"
sudo kextload "/Library/Application Support/VirtualBox/VBoxUSB.kext" -r "/Library/Application Support/VirtualBox/"
}
case "$1" in
unload|remove)
unload
;;
load)
load
;;
*|reload)
unload
load
;;
esac
Run this script after you attempt to install virtualbox. Keep approving the kexts until the script runs cleanly:
Run brew cask reinstall --force virtualbox
Kudos to Dan Stroot for the solution.
Solution so far:
Ok, this is a bit of a hassle but we did manage to make it kind of work.
The issue is related to the system not deleting all files from the virtual box installation.
Using the terminal to search for files with virtualbox in the name of the file, we found (non vagrant related) files that were still in the system.
Problem is these files cannot be deleted even using sudo. So we had to reboot the system pressing cmd + r so you go into a troubleshooting system and not the normal OS environment. In there, you can open the terminal and run "csrutil disable", then reboot the system.
This turns off System Integrity Protection for your system so it is NOT RECOMMENDED, but we had to do this in order to delete these files that we couldn't delete before.
So after deleting these files, we ran the install again and now it worked! Immediately afterwards I tried running vagrant and now it worked as expected.
My final problem now: after making sure that vagrant is working, I went back to starting the computer again pressing cmd + r, open the terminal and run "csrutil enable" and reboot.
Back in the normal OS X I try to run vagrant and get an error again. So at the moment I had to go back again, to disable the csrutil, which is NOT RECOMMENDED, but it's as of this moment the only thing that works for me.
I have not tried running all these steps again.
The answer from llene works perfect for me. The key is that, when you already tried to install and not succeed, you have to do exactly this steps:
Run VirtualBox installer
Run install from .pkg file, it will fail at the validation step, it's ok
close installer and run it again, but now choose uninstaller.tool file, inside (DO NOT DELETE THE INSTALLER DEVICE yet)
eject virtualbox from your devices (in the left panel of finder)
After, go to System Preferences -> Security and Privacy -> General and approve the blocked software from ‘Oracle America’, that will appear there
6) Run install again from the same .pkg file. Now it should complete successfully
Managed to solve it.
Eject the VirtualBox image from: Finder > Devices
Remove VirtualBox device
Now allow the exception in: System Preferences > Security & Privacy
Then try to install from the .dmg again so that it remounts the device.
Now its working fine for me.
For those using homebrew, run 'brew install caskroom/cask/virtualbox', which will fail the first time. Then go to System Preferences>Security & Privacy>General as described above, where, at the bottom, there should be a message about the software install being blocked. Click the 'Allow' button next to this message, then go back to your terminal. Run the homebrew command again and this time it will work.
So.. after struggling a lot about this, and after spend a lot of time in stack overflow.. I combined some answers and finnaly get to install virtualbox in my 10.13 osx.
So:
As I read, Sierra has a new security feature that blocks some external programs. During virtualbox installations you can check Preferences > Security & Privacy > General. You will see that Oracle (virtualbox) is being blocked.
So, what I did was:
Run this command at terminal to disable that new sierra gatekeeper: sudo spctl --master-disable
Open the virtualbox install program, and click unistall to make sure there is no trace of the previous installation attempts.
In the desktop, or in the finder left sidebar (in devices) if there is any virtualbox image, you have to eject them.
Delete the previous virtualbox program and download a new one.
Now, if these steps work for you as they worked for me, you will be able to install virtualbox.
(After this you can re-enable the gatekeeper feature running sudo spctl --master-enable
When running the excellent Disk Arbitrator app, Deactivate it — when active it blocks all mounts and optionally remounts them read-only
which, e.g., prevents Spotlight from trashing USB drives but (d-uh)
gotta remember to turn it off when appropriate.

Run a C++ program in Clion as root

I'm trying to run a program written in C++ by using CLion v1.2 as super user. Anyone here knows how to run it as superuser? I'm using CMake.
I solved this by remote debugging on local machine. I run gdbserver with root privileges and connected to it from CLion.
To start gdbserver sudo gdbserver :port myapp, configure remote GDB debug with port
This was already implemented on CLion, starting 2020.3:
https://www.jetbrains.com/help/clion/debug-as-root.html
If you are asking to run the debugger as sudo/administrator, I had the same issue. On Linux you can open CLion as sudo and gdb will not have root permission issues running an executable:
sudo ./clion.sh
I would guess that you could right click in Windows and "Run as administrator" to get the same result.
There is a feature request into JetBrains to run the debugger as root that could use more up voting.
A workaround is:
From https://www.jetbrains.com/help/clion/attaching-to-local-process.html#prereq-ubuntu
If you are using CLion on Ubuntu (or probably, on some other Linux distribution), upon the first attempt to attach to the local process you can get the ptrace: Operation not permitted. error message. To disable it and enable attach to the local process feature, do the following:
To disable this restriction temporarily, enter the command:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
To disable this restriction permanently, open the file /etc/sysctl.d/10-ptrace.conf for editing and change the line kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0. To apply the changes, enter:
sudo service procps restart or restart your system, at your choice.
You can create a bash script to help you. For example, run.sh:
#!/usr/bin/env bash
echo $LOGIN_PASSWD | sudo -S yourExecutable --with=some-arguments
Don't forget to chmod a+x run.sh, and export the password of current account as an environment variable in Run/Debug Configurations.

How to execute certain command after new kernel is installed

Every time a new kernel is downloaded and installed by unattended upgrades Virtual Box service gets broken.
So, when I try to start a VM box after reboot I get the error:
VirtualBox is complaining that the installation is incomplete. Please
run `VBoxManage --version` to see the error message which should contain
instructions on how to fix this error.
To fix it I issue sudo dpkg-reconfigure --priority low virtualbox-dkms
How can I automate that?

Resources