Git not working after High Sierra Upgrade

Published: Sep 30, 2017

which git returns normally.

But running git status returns xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Ran xcode-select --reset appears to have worked because git status works fine. But the real fix is xcode-select --install.

Last modified: September 30, 2017 10:02 pm
Posted in: Snippets


Published: Sep 26, 2017


SELECT @@GLOBAL.sql_mode;


alias ll='ls -lah'
alias ss='sudo service apache2 restart'


echo "Host
 IdentitiesOnly yes
 StrictHostKeyChecking no
 IdentityFile ${USER_HOME}${PRIVATE_KEY}" | sudo tee $USER_HOME.ssh/config > /dev/null
create a branch in your git repository, commit the patch to this branch, and create a PR with our main git repo at


Debian Stretch

PHP 5.6 on Xenial

sudo apt-get update
sudo apt-get install -y vim git curl

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

sudo apt-get install apache2
sudo apache2 -t

sudo apt-get install -y mysql-server

sudo apt-get install -y php5.6 libapache2-mod-php5.6 php5.6-mcrypt php5.6-mysql 

sudo apt-get install -y php5.6-curl php5.6-bcmath php5.6-gd php5.6-imap php5.6-json php5.6-xmlrpc php5.6-xsl php5.6-mbstring php5.6-soap php5.6-xml php5.6-zip php5.6-intl php-imagick php-gettext php-xdebug

sudo service apache2 restart

php -v

# disable opcache for php and php-cli
sudo vim /etc/php/5.6/apache2/php.ini

# set ServerName
sudo vim /etc/apache2/apache2.conf

sudo a2enmod rewrite
sudo service apache2 restart

# verify apache mods
apachectl -M | sort

sudo chown -R carlos:www-data /var/www/html

curl -sL | sudo -E bash
sudo apt-get install -y nodejs
curl -sL | bash -
apt-get install -y nodejs
apt-cache search php dom
sudo apt-get install php5.6-*
will install everything related to php5.6
// upload local .sql into production
/Applications/MAMP/Library/bin/mysql -udnuser -p -h dbname < dbfile.sql
\<Files "*"\>
  Order allow,deny
  Deny from all
:%s/\r//g only works when:

set ff=unix, which when done, automatically converts all CRLF to LF
set ff=dos and CR is a rogue char that is not preceded by LF, e.g., inserted with C-V C-M.

CR in LF CR pairs will not be found.
Therefore, if all you want is to convert every LF CR to LF, you should use:

:set ff=unix
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

civibuild create my-47 \
--type wp-demo \
--civi-ver master \
--cms-ver 4.7.5 \
--url http://my-47.localhost \
--admin-pass admin


utf8mb4_unicode_520_ci to utf8mb4_unicode_ci
 * Disable Posts' meta from being preloaded
 * This fixes memory problems
function nlf_pre_get_posts( WP_Query $wp_query ) {
	if ( in_array( $wp_query->get( 'post_type' ), array( 'my_post_type_1', 'my_post_type_2' ) ) ) {
		$wp_query->set( 'update_post_meta_cache', false );

// Only do this for admin
if ( is_admin() ) {
	add_action( 'pre_get_posts', 'nlf_pre_get_posts' );
error_log("Memory Usage: " . (memory_get_usage()));
add_action( 'plugins_loaded', 'checking_memory_cl' );
function checking_memory_cl() {
    error_log("Memory Usage at plugins_loaded: " . (memory_get_usage()));

add_action( 'after_setup_theme', 'checking_memory_cl2' );
function checking_memory_cl2() {
    error_log("Memory Usage after setup theme: " . (memory_get_usage()));

add_action( 'wp_loaded', 'checking_memory_cl3' );
function checking_memory_cl3() {
    error_log("Memory Usage after wp_loaded: " . (memory_get_usage()));
UPDATE wp_posts SET guid = replace(guid, '','');


If you’ll be using the disk on a Windows computer, choose the Master Boot Record partition scheme (also known as “fdisk”).

If you’ll be using the disk only with Mac computers, choose GUID Partition Table.


Put your rsync command in a shell script so you sync to a release directory and the swap to symlink from www->release1 to www->release2. The script will only take 5min to write and test, but it means you have no downtime and nothing breaks if rsync cuts out halfway through.

Last modified: November 28, 2017 12:03 am
Posted in: Snippets

CiviCRM HelloTest.php

Published: Sep 14, 2017

Totten does phpunit4 HelloTest.php at but my result was (on both 4.6.4 and 4.7.23):

1) HelloTest::testGet
session_start(): Cannot send session cookie - headers already sent by (output started at phar:///home/vagrant/buildkit/bin/phpunit4/phpunit/Util/Printer.php:134)

Please make sure "session.auto_start": "1" in php.ini and verify with cv api system.get

Last modified: September 14, 2017 5:39 pm
Posted in: Snippets

Multiple SSH keys for a single server

Published: Sep 08, 2017

Attempting to git clone:

Cloning into 'vagrant_vm'...
repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[Aim: create new key pair to access work bitbucket account]

Working from home, here’s how I went about setting up the environment on my personal Mac:
1. Created SSH key pair (, bitbucket_work)
2. Logged into my work bitbucket account and added the public key
3. Added the private key to the ssh agent (OS X)
4. Attempted to git clone and failed.

Turns out the git clone command would try using the private key associated with my personal bitbucket account. Tried vim ~/.ssh/config and added the lines but nothing.

Running ssh-add -l shows the agent’s loaded strings and there it was: the git clone using my personal key.

Carloss-iMac:Sites carlos$ ssh-add -l
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/strasmore_byl (RSA)
2048 SHA256:xxxxxxxxxxxxxx /home/vagrant/.ssh/bitbucket_personal (RSA)
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/2017FEB09_lithium_backyardlogs (RSA)
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/lithium_lucs_17246 (RSA)
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/bitbucket_work (RSA)

Ran ssh-add -D to clean out all keys.

Carloss-iMac:Sites carlos$ ssh-add -D
All identities removed.

Added the new private key to the agent (bitbucket_work) and ta-dah. Git clone works.

Last modified: September 8, 2017 1:23 pm
Posted in: Snippets

cannot redeclare civicrm_api3_pcp_create

Published: Aug 21, 2017

If Vagrantfile has
nfs: true as in
config.vm.synced_folder ".", "/vagrant", nfs: true,
then cv/api explorer will cry cannot redeclare civicrm blah blah blah

Last modified: August 21, 2017 8:22 pm
Posted in: Snippets

cv and civix blank output

Published: Jun 19, 2017

CiviCRM 4.6.4, Vagrant

Running cv vars:show outputs nothing
including adding -vvv
and civix civicrm:ping -vvv output is

[Bootstrap] Options: {
    "dynamicSettingsFile": "phar:///usr/local/bin/civix/vendor/civicrm/cv/settings_location.php",
    "env": "CIVICRM_SETTINGS",
    "prefetch": false,
    "settingsFile": null,
    "search": true,
    "cmsType": null,
    "httpHost": "",
    "output": {

[Bootstrap] Find settings file
[Bootstrap] Load supplemental configuration for "/vagrant/mysite/wp-content/plugins/civicrm/civicrm.settings.php"
[Bootstrap] Load settings file "/vagrant/mysite/wp-content/plugins/civicrm/civicrm.settings.php"

Turns out that if my civicrm.settings.php has variables, wont work!


$wordpress_root = '/vagrant/mysite/';
$website_address = '';

define( 'CIVICRM_UF_BASEURL'      , $website_address );

global $civicrm_setting;

// Temporary Files (System Settings > Directories)
$civicrm_setting['Directory Preferences']['uploadDir'] = $wordpress_root . 'wp-content/plugins/files/civicrm/upload' ;

// Images (System Settings > Directories)
$civicrm_setting['Directory Preferences']['imageUploadDir'] = $wordpress_root . 'wp-content/plugins/files/civicrm/persist/contribute' ;
Last modified: June 19, 2017 4:47 pm
Posted in: Snippets

CiviCRM Dashboard Redirects

Published: Mar 26, 2017

CiviCRM 4.6.4 in vagrant with apache.

Opening the CiviCRM dashboard auto redirects to an ISP page. Turns out the site cannot call itself. Vagrantfile has

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.ssh.forward_agent = true "private_network", ip: ""

To solve, edit the vm’s /etc/hosts and in addition to the localhost, add the Vagrantfile’s private_network ip:

echo '
' | sudo tee /etc/hosts > /dev/null
Last modified: September 8, 2017 1:25 pm
Posted in: Snippets