Author Archives: Sawant Shah

Resolution of Ansible Issues on OS X Mavericks

Getting started with Ansible on OS X Mavericks. While following the installation instructions, it broke down on the final step, twice.

$ ansible all -m ping --ask-pass

It first broke down with the following message (upon entering an empty password):

127.0.0.1 | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue

Then tried entering the password for my logged-in user, which resulted in the following error:

127.0.0.1 | FAILED => to use the 'ssh' connection type with passwords, you must install the sshpass program

Solution 1: This was resolved with the solution found here.

After this, things were still breaking down, so I turned the -vvvv flag on. Here’s the output with -vvvv flag:

$ ansible all -m ping --ask-pass -vvvv
SSH password:
<127.0.0.1> ESTABLISH CONNECTION FOR USER: User
<127.0.0.1> REMOTE_MODULE ping
<127.0.0.1> EXEC ['sshpass', '-d6', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/User/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1396129886.05-214459499538981 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1396129886.05-214459499538981 && echo $HOME/.ansible/tmp/ansible-tmp-1396129886.05-214459499538981'"]
127.0.0.1 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/Users/User/.ansible/cp/ansible-ssh-127.0.0.1-22-User" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host 127.0.0.1 port 22: Connection refused

 Solution 2: Go to System Preferences > Sharing, and enable Remote Login option:

OS X - Sharing - Remote Login

 

You will finally get the following output:

127.0.0.1 | success >> {
"changed": false,
"ping": "pong"
}

That’s all folks.

Laravel Blank (White) Screen of Death on Mac OS X

Kept getting a blank screen / white screen of death upon copy-pasting a new Laravel project from a Windows machine to Mac OS X (Mavericks – PHP 5.4). Nothing helped. No errors were shown or logged. Whoops was not showing either. It was probably a permissions issue, but no debugging help.

Got to the bottom of the issue only after installing a fresh copy of Laravel 4.1:

composer create-project laravel/laravel project-name --prefer-dist

This emitted the following error upon browsing project in the browser:

ErrorException
file_put_contents(/project_path/app/storage/meta/services.json): failed to open stream: Permission denied

That was it: permissions issue!

So here is the solution: set permissions of all files and folders in app/storage. So, go to your project root from Terminal, and enter the following:

find app/storage -type d -exec chmod 777 {} \;
find app/storage -type f -exec chmod 777 {} \;

That’s it!
 

Unable to Upload Files into WordPress on Localhost – OS X Apache

Came across a very weird bug in WordPress 3.7.1, which was not letting me upload any image/file through the Media Uploader. It was constantly giving the following error:

“logo.png” has failed to upload due to an error
Unable to create directory /content/uploads/2013/11. Is its parent directory writable by the server?
  • I tried changing folder permissions to 777; error.
  • Tried changing folder owner to _www; error.
  • Tried changing folder group to _www; error.

None of these solutions worked.

I have a custom folder structure, where wp-content has been renamed to content. So I turned to wp-config.php file. This is how it looks like in my wp-config.php:

define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/content' );
define( 'WP_CONTENT_URL', '/content' );
// Specify Uploads folder
define( 'UPLOADS', '/content/uploads' );

I tried changing the last line back to /wp-content/uploads (and renamed the folder), but still the same error! I was pulling my hair at this point!

Then I don’t know what occurred to me, and I commented out that last line. And voila! It worked!

Now I have no clue why explicitly defining the uploads folder was causing the issue, whereas on the WordPress Codex that’s exactly how the uploads folder – on a custom path – is supposed to be defined. Anyway, if anyone is having this issue in WordPress 3.7.x (or other versions), simply try removing this line from your wp-config.php file:

// define( 'UPLOADS', '/content/uploads' );

That’s all folks.

Local Websites in Apache after updating to OSX Mavericks 10.9

If after updating OS X to Mavericks, your local Apache setup stopped returning the websites that you had setup locally, then it’s highly likely that your httpd.conf has been overwritten. However, before it was overwritten the Mavericks setup created a backup of the httpd.conf file, httpd.conf.pre-update, in /private/etc/apache2/ folder. You can use diff tools to find out the difference between the new and old httpd.conf files. Most likely, the inclusion of httpd-vhost.conf file must have been commented out, so uncomment that (along with any other changes that you might have had in the older httpd.conf file).

Reference: Quick Tip: Getting Apache Up And Running After Updating To Osx Mavericks (10.9)

Installing from Packagist using Composer

If you have Composer already installed, then to install a PHP package from Packagist, such as Generators package for Laravel, type the following on the terminal in your web project directory:

$ composer require ways/generators

You will be asked about the version of the package that needs to be installed:

Please provide a version constraint for the way/generators requirement: 1.0.*

I required the latest, which was 1.0.x-dev; so something like 1.0.* would get the latest one in 1.0 branch.

Composer will install the dependencies first, and then install the required package:

composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  – Installing mockery/mockery (dev-master 28c7769)
  Cloning 28c77695ac5167e533f86e0268c0a83ef1ac693a

  – Installing way/laravel-test-helpers (dev-master 869388b)
  Cloning 869388b555c68c0dc74297eca83893c8500d8221

  – Installing mustache/mustache (dev-master v2.3.1)
  Cloning v2.3.1

  – Installing way/generators (dev-master a04a2c9)
  Cloning a04a2c9cf6704f107f1a4e534d898d46f076d3de

Writing lock file
Generating autoload files
Generating optimized class loader…
Compiling common classes…

That’s it. The package has been installed in your web project. In your Laravel app, it gets installed inside the vendor directory.

PHP 5.4 on OS X Mountain Lion

Installing PHP 5.4 on Mac OS X Mountain Lion from Source

Here is how to install (or update) PHP 5.4 on Mac OS X Mountain Lion from source. This walkthrough is an extension of Upgrading the Native PHP Installation on OS X Mountain Lion. So first follow that, and if you come across any issues during the ./configure part of PHP installation, then come back here. This is what you will get at the end:

PHP 5.4 on Mac OS X

Here are the step-by step instructions that I followed to get PHP installed from source on Mac OS X Mountain Lion:

Step 1: Follow the Yellow Brick Road

Follow Upgrading the Native PHP Installation on OS X Mountain Lion (tutorial 1). Ideally, this link would be the only article you have to go through to setup PHP 5.4 on OS X Mountain Lion. In my case, it wasn’t. So we move to step 2, where I encountered the first error during ./configure part of PHP installation. The rest of this walkthrough assumes that you have followed the walkthrough from the original tutorial up till the ICU installation section, right before the “Installing” heading.

Step 2: Install libpng to tackle: configure: error: png.h not found.

Upon executing the following:

$ ./configure  \
--prefix=/usr  \
--mandir=/usr/share/man  \
--infodir=/usr/share/info  \
--sysconfdir=/private/etc  \
--with-apxs2=/usr/sbin/apxs  \
--enable-cli  \
--with-config-file-path=/etc  \
--with-libxml-dir=/usr  \
--with-openssl=/usr  \
--with-kerberos=/usr  \
--with-zlib=/usr  \
--enable-bcmath  \
--with-bz2=/usr  \
--enable-calendar  \
--with-curl=/usr  \
--enable-dba  \
--enable-exif  \
--enable-ftp  \
--with-gd  \
--enable-gd-native-ttf  \
--with-icu-dir=/usr  \
--with-iodbc=/usr  \
--with-ldap=/usr  \
--with-ldap-sasl=/usr  \
--with-libedit=/usr  \
--enable-mbstring  \
--enable-mbregex  \
--with-mysql=mysqlnd  \
--with-mysqli=mysqlnd  \
--without-pear  \
--with-pdo-mysql=mysqlnd  \
--with-mysql-sock=/var/mysql/mysql.sock  \
--with-readline=/usr  \
--enable-shmop  \
--with-snmp=/usr  \
--enable-soap  \
--enable-sockets  \
--enable-sysvmsg  \
--enable-sysvsem  \
--enable-sysvshm  \
--with-tidy  \
--enable-wddx  \
--with-xmlrpc  \
--with-iconv-dir=/usr  \
--with-xsl=/usr  \
--enable-zip  \
--with-imap=/usr/local/imap-2007 \
--with-kerberos \
--with-imap-ssl \
--enable-intl \
--with-pcre-regex  \
--with-pgsql=/usr  \
--with-pdo-pgsql=/usr \
--with-freetype-dir=/usr/X11 \
--with-jpeg-dir=/usr  \
--with-png-dir=/usr/X11

It ended with the following lines:

checking for jpeg_read_header in -ljpeg... yes
If configure fails try --with-vpx-dir=<dir>
configure: error: png.h not found.

I tackled this by installing libpng through homebrew (you should have homebrew installed from the earlier step in the original tutorial):

$ brew install libpng

Step 3: Install freetype to tackle: configure: error: freetype.h not found.

Executing ./configure line again ended with another error:

configure: error: freetype.h not found.

Tackled it by installing freetype:

$ brew install freetype

Step 4: Tackling: configure: error: utf8_mime2text() has new signature …

Executing ./configure again, it threw a new error this time:

checking for U8T_DECOMPOSE...
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

This took me the longest to solve! I tried the following:

$ brew install openssl

But that didn’t solve the problem. The error turned out to be related to the PHP IMAP extension, for which, as I found out, we require to compile IMAP from source.

Step 4.1: Compiling IMAP from Source on OS X Mountain Lion

I followed Step 1 from Snow Leopard PHP and IMAP Support article to get IMAP compiled on my Mac (no need to follow the rest of the steps), which made the error in step 4 go away, but introduced a new one.

Step 4.2: Helping OS X find libc-client.a

Now the new error that I received when executing ./configure was:

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

For this, I got a little help from PHP IMAP support in Mac OS X Lion without recompiling PHP: I executed the following (while in the /usr/local/imap-2007 folder):

$ sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

This fixed the error.

Step 5: Do you want PHP with International Support?

Yet another error upon executing ./configure. Installing PHP manually on Mac OS X is such a pain!

checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.

Turns out that this resulted from a a step I skipped from the original tutorial, which walked through installing ICU for enabling international support. If you are getting this error, make sure you followed that step. However, if you don’t really want international support in PHP on your system, you can remove the –enable-intl option while running ./configure. I did the latter and finally got through the ./configure command!

Milestone Reached: Configured successfully!

Upon successful execution of ./configure, you will see the following:

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands

Yay!

Oh wait, there is more to do before PHP 5.4 is installed on OS X Mountain Lion.

Step 6: Make PHP

Followed the next part in tutorial 1, which involved running:

$ make test

The tutorial said that it will take up to 30 minutes, so we need to wait. After a while, the process ended with the following:

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.

This probably means success as far as make is concerned, so I went ahead with the next part of the tutorial. It will also ask you to send the test result to PHP folks and ask for your email address if you choose to.

Step 7: Install PHP

$ sudo make install

It ended quickly. Looks like everything went fine.

Step 8: Check PHP version to make sure you got everything right!

Let’s check the PHP version:

$ php -v

This resulted in:

PHP 5.4.10 (cli) (built: Dec 21 2012 15:28:12)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Yayy!! Installing PHP 5.4 on Mac OS X, or updating it, was not easy, but in the end you should have PHP updated to version 5.4, just like I did! While doing it, we gained the experience of building, compiling and installing a software from source. It was worth it.

Celebrate! 

What is Node.js? What is Node.js good for? An infographic!

In order to understand Node.js, one has to grasp what it is and, more importantly, what it is not! Here I am sharing some fantastic resources that would help a beginner understand Node.js better. Starting with an infographic explaining what is Node.js? And what is it used for and what is Node good for:

What is Node.js? Getting to know Node.
Courtesy of: Engine Yard

Also check out the following helpful links for further reading on Node.js:

Macbook Retina Apps – Retina Ready Apps for the Retina Macbook

If you are looking for Macbook Retina Apps, then go to this website: Retina Mac Apps.

This excellent resource lists all the apps that are Macbook Retina ready. It is constantly updated with new apps. I wrote in my previous post about the lack of update of Adobe Creative Suite for Macbook Retina. Now, as I found out on Retina Mac Apps, an update is available for Dreamweaver CS6, Photoshop CS6, Lightroom CS6 and Illustrator CS6. Still no update for PDF Reader? Read the solution for a compatible Macbook Retina PDF Reader on OS X Mountain Lion.

macbook-pro-vs-retina-display-zoom

Macbook Pro Retina PDF Reader / Viewer

If you just want to find out about the appropriate Macbook Pro Retina PDF Reader, jump straight to the recommendation, or read on for the rant.

The Apple Macbook Pro Retina laptop is, in my opinion, the best laptop that developers or designers can lay their hands on. And it’s undoubtedly the best laptop for anyone to lay their eyes on. The Retina Macbook Pro offers crisp, crystal clear on-screen text. But no matter how good the screen, if the software support for such hi-resoultion display is not good enough then the retina display can be more of a problem. And although its been a few months since Apple released their Macbook Pro Retina laptops, some major software vendors have still not offered upgrades to their software to support the hi-DPI display of the Retina laptop.

Microsoft Office, Adobe Creative Suite and Mozilla Firefox are the major software that lacked Retina support. Microsoft released an updated version of Office for Mac recently to support Retina resolution. Mozilla is building Retina support in Firefox version 18 – it has been released as beta, whereas the final version is planned for a January release. Adobe pledged Retina support late August for its Creative Suite 6 – Photoshop and Lightroom in particular, but there has been no further word on it since then. For now I am using Pixelmator, which supports Retina display and is serving very well as a Photoshop alternative for general designing tasks.

Finally, there is Adobe PDF Reader – a major problem as the text of PDFs gets pixelated, which puts a lot of strain on eyes. It’s also something major because Adobe PDF Reader is not only used by developers and designers, but also by regular folks. The doubling of text/pixelation puts strain on the reader’s eyes and one is unable to continue to read for long.

Macbook Pro Retina PDF Reader

The best software for reading PDFs on a Macbook Pro Retina comes pre-installed with OS X Mountain Lion. It’s Preview. Yes, it appears as if it’s only for images, but it works great with PDFs too, providing a crystal clear reading experience. So we can get rid of Adobe PDF Reader as it serves no purpose on Macbook Retina anymore, especially with the lack of hiDPI support.

Here is more on Preview.