Installing watchman when having a non-standard homebrew install - homebrew

I am using React Native which needs watchman. When running react-native run-ios, I see this error.
watchman --no-pretty get-sockname returned with exit code=1, signal=null,
stderr= 2017-05-05T08:17:49,256: [2110218240] while computing sockname:
failed to create /usr/local/var/run/watchman/foo-state: No such file or directory
After investigating this, it seems that it is caused by not having a standard /usr/local/ homebrew install.
Is their a way to change the statedir being used by watchman?

I was able to solve this issue by creating the directory and giving my user the ownership of the directory.
sudo mkdir /usr/local/var/run/watchman/foo-state
sudo chown -R myusername /usr/local/var/run/watchman/foo-state

From watchman --help:
--statefile=PATH Specify path to file to hold watch and trigger state
So I think you need to use the --statefile option.

The safest way to resolve this is to delete the state dir. Run rm -rf /usr/local/var/run/watchman/root-state. This resolved the same problem for me.

Related

How to fix Shell Script Invocation Error MapFileParser.sh: Permission denied in Xcode

I'm working on a IOS Game that I built using Unity and I'm trying to get it to build on Xcode. However I keep getting this Shell Script Invocation Error "/Users/masterolu/Downloads/ShoeJackCityBuilds/iOS/MapFileParser.sh: Permission denied".
I've tried to use chmod +x /Users/masterolu/Downloads/ShoeJackCityBuilds/iOS/MapFileParser.sh but for some reason my machine doesn't recognize the chomd command anymore. I tried to reinstall it by using sudo apt install --reinstall coreutils but in order to use apt I need a JDK(Java Developer Kit). So I install the latest JDK and when I try to reinstall chomd my terminal says "Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home/bin/apt" (-1)". At this point I decided it's best to come and ask for help.
Any ideas on how to fix this error in Xcode or how to install chomd so my app can run?
So, apparently Apple likes to disable the execution permission of all the shell scripts that have not been created on your machine (i.e. downloaded from web, cloned from repo) so what you have to do is to open a terminal inside the project folder and run chmod -x MapFileParser.sh, that should fix it.
I have also done it on the process_symbols.sh just to be sure it runs.
## EDIT ##
My solution for my gihub action was this as the -x version did not work correctly for my scenario.
- name: Update scripts permissions
run: |
pwd
sudo chmod 755 MapFileParser.sh
sudo chmod 755 process_symbols.sh
This works for me:
chmod 777 MapFileParser.sh

Is it safe to force remove /usr/local/lib/docker to fix a Homebrew permission issue?

I'm trying to cleanup my installed packages using brew cleanup but keep getting the message Permission denied # apply2files - /usr/local/lib/docker/cli-plugins.
I tried changing the ownership of /usr/local/lib/docker/cli-plugins using sudo chown $(whoami) /usr/local/lib/docker/cli-plugins then ran brew cleanup again but this got the same result.
It might be worth noting that I do not use the Docker application anymore and don't even have it installed anymore. So I was wondering if simply force removing the /docker directory using the rm -rf /usr/local/lib/docker/ command would help? Or would that do more harm than good?
I don't think there would be any issue of deleting or reinstalling /usr/local/lib/docker/. You should be always re-installing the right Docker app and brew link it for the use.
But before you are doing that, I'd recommend you to run brew doctor first.

PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/pdo_sqlite.so' with Jenkins

I'm getting this warning when running the phpunit test suite in Jenkins pipeline.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/pdo_sqlite.so' - /usr/lib/php/20160303/pdo_sqlite.so: undefined symbol: sqlite3_column_table_name in Unknown on line 0
However this warning is not thrown when running the test suite directly in terminal.
I have PHP 7.1 in my system and this is the only PHP version I have installed. php7.1-sqlite3 is installed.
Thank you in advance.
As far as I have found out, there is a faulty file in /usr/local/lib called libsqlite3.so.0 which points to libsqlite3.so.0.8.6. I renamed the file in case it was needed for something. With the command:
cd /usr/local/lib
sudo mv libsqlite3.so.0 ./libsqlite3.so.0.back
But you can also delete it:
rm libsqlite3.so.0
The thread that lead me to the answer: link
This solved my problems, and I hope they solve yours as well :)
I had this same issue with PHP 7.1 on Ubuntu 16.04.
Running the following fixed the issue for me:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1-sqlite3
Have you built SQLite from source? If yes, enable Column metadata and recompile with
CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" ./configure
make
sudo make install
Have fun using the cutting edge SQLite.
Reference - https://www.sqlite.org/compile.html#enable_column_metadata

Unable to add or copy gas-preprocessor.pl in usr/bin on macOS Sierra

Im trying to add gas-preprocessor.pl to usr/bin. Adding it to usr/local/bin does not work.
I tried switching to root user and performing the action. The operation to copy or add this file is still not permitted.
Thanks for help in advance.
Since creating a soft link doesnt work for me, this link helped for the work around. http://tips.tutorialhorizon.com/2016/07/30/docker-usrlocalbindocker-machine-permission-denied/
Command: sudo chown -R $(whoami) /usr/local/bin
sudo ln -s gaspreprocessor/path /usr/bin/local/gaspreprocessor
Be sure gaspp is executable

Built stuck at 0.0% while bundling index.ios.js

I don't know exactly why but all my react-native projects cannot build anymore today and I'm stuck with a the Bundling of index.ios.js at 0.0%.
I tried a couple of things but all my projects got the same issue.
NOTE: This workaround is for macOS.
Found out that the culprit was watchman 4.7.0.
My issues started after having upgraded to watchman 4.7.0 using brew.
Looks like there's an issue in this new version of watchman:
watchman issues 358.
At the end I solved my issue removing the content of the /usr/local/var/run/watchman/ folder.
I tried several things: the above answer, launchctl unload, restart, reinstall... You name it. Here's how I fixed it on MacOS:
TL;DR: Remove brew version and follow official documentation to compile from source. Use flags on configure: --enable-statedir=$HOME/.watchman --without-python --without-pcre
Reasoning: I don't need python bindings. I also suspect some permission issues and thought using my home would be safer than default path.
steps:
brew rm watchman
(just to be safe) launchctl unload -F ~/Library/LaunchAgents/com.github.facebook.watchman.plist
(just to be safe) restart mac
git clone https://github.com/facebook/watchman.git
cd watchman
git checkout v4.9.0 // Prefer lastest version here.
brew install autoconf automake libtool // Compilation tools
./autogen.sh
./configure --enable-statedir="$HOME/.watchman" --without-python --without-pcre
make // Wait... It'll compile the .o files
make install // If it fails try with sudo but it shouldn't.
After make install it should be in your path here: /usr/local/bin/watchman
Try to watchman version or something. Try to see if it fixed your problem.
Keep in mind most people have their stuff in /usr/local/var/run/watchman/. Our equivalent is now ~/.watchman/
Let me know if this helps you. :)
run the following command
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
This also may happen in case your node dependencies are not installed, e.g. node-modules/ in .gitignore and repo is freshly-pulled.
In this case, your should do npm install of yarn (in case you are using yarn).

Resources