Saturday, April 9, 2016

Composer Update Failed on Dreamhost - killed for excessive resource usage

Problem:
While working on a pet project, I decided to use Laravel 5 on my Dreamhost shared server (where most of my prototype/hobbies go). I was able to get composer running fine with the exception of when I would try to run composer update. Composer can sometimes take a bit of resources, and unfortunately Dreamhost shared servers are pretty slim. I kept getting the following message.

Loading composer repositories with package information
Updating dependencies (including require-dev)

Yikes! One of your processes (php, pid 3726) was just killed for excessive resource usage.
Please contact DreamHost Support for details.

Killed

Solution:
It turns out that one of the heaviest parts of running composer update is the point as which the composer.lock file is updated and PHP tries to determine new packages, etc. If we generate the composer.lock file outside of Dreamhost (like on your local machine) and then move the file over, we can bypass this by running composer install.  For this pet project, I just add the composer.lock to my source version control to make things simpler when moving the file back and forth.

Good luck!

Friday, February 26, 2016

Ionic V2 - Could not find any version that matches com.android.support:support-v4

Problem: 
Lately I've been playing around with mobile app development using Ionic V2 (with Cordova). While testing it on my older mobile device (Galaxy S4) I noticed that the native web view (Android browser) seems to be slow and didn't play any of the Material Design animations. I found CrossWalk and started trying to add it to my project:

> ionic browser add crosswalk

I was able to get older versions working (14, 15), but when trying to use CrossWalk 16, I ran into an error:

ANDROID_HOME=/home/me/android-sdk-linux
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
embedded
org.xwalk:xwalk_core_library:16+

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugCompile'.
   > Could not find any version that matches com.android.support:support-v4:[13.0.0,).
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
         https://repo1.maven.org/maven2/com/android/support/support-v4/
         https://download.01.org/crosswalk/releases/crosswalk/android/maven2/com/android/support/support-v4/maven-metadata.xml
         https://download.01.org/crosswalk/releases/crosswalk/android/maven2/com/android/support/support-v4/
         file:/home/me/android-sdk-linux/extras/google/m2repository/com/android/support/support-v4/maven-metadata.xml
         file:/home/me/android-sdk-linux/extras/google/m2repository/com/android/support/support-v4/
     Required by:
         :android:unspecified > org.xwalk:xwalk_core_library:16.45.421.19

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Solution:
It turned out I didn't have everything I needed installed from the Android SDK Manager. I found that I needed to have from Extra:

  • Android Support Library
  • Google Repository
  • Local Maven repository for Support Library

 Once I had these installed, my build was able to succeed and the app feels slightly more responsive but I still do not get Material Design animations.

Tuesday, May 19, 2015

cURL on Windows: cURL error 60: SSL certificate problem: unable to get local issuer certificate

Problem:

While running some unit tests on a managed project, I ran across an issue from the Guzzle library.

cURL error 60: SSL certificate problem: unable to get local issuer certificate


Solution:

The latest version of cURL does not ship with a bundle of root certificates. This is due to security concerns in the past. Instead, they have you provide the root certificates that should be valid as certificate authorities. Most of us are really only concerned with the main ones likes Equifax, GlobalSign, and Verisign.

There are several ways to solve this problem, but what I decided to do was allow PHP on my system to always reference the same PEM file instead of other methods (like telling cURL not validate the peer certificate - please note this is a bad idea!).

In order to solve this problem, we need to obtain a version of this cacert.pem file that has not been corrupted. I found mine from the cURL web site which links to Mozilla.orgs CAs.

Once I had downloaded the pem file, I placed it in a common development directory on my Windows machine.

Last, we just need to tell PHP where to look for this file. Open your php.ini file and set the following property*:

openssl.cafile="C:\dev\cacert.pem"


Hope this solves some head scratching.



*This may change if you use something other than OpenSSL.

Monday, April 13, 2015

Git shows modified files but no local changes have been made

Problem:

I checked out updated my master branch to work on some hot fixes, but one I had pulled in the latest master branch, I found two files which were being tracked as modified. I didn't have any local changes to these files before. Where did these come from?





Solution:
For me this was due to git not handling case sensitive changes. Another developer had changed an upper case letter to lower case for a file name. Here is how I solved the problem.

Rename the directory in question to something else. Git should now show the files as deleted. Specifically `git rm` the directory with the old name and casing (you may need to force it) and run `git status` to be sure that only the now incorrect casing directory is staged for commit. Now commit your changes.





Manually rename the directory back to the expected format (the newest format) of it's title. Run `git status` again. If you still see one or more of those files as modified, checkout the latest version of the file. Note: If the directory is no longer around, manually create it with the correct casing and then checkout the files it has from your repo.



Now check your project state. You should have a clean state with 1 commit ahead of master.



Tuesday, March 31, 2015

Composer Update: fatal: No such remote 'composer'

Problem: 

While working on a composer library for a client, I ran into an issue where running the command:

composer update

Caused an error to be printed on the screen that read:

fatal: No such remote 'composer'



Solution:

After playing around with it for some time, I went to the web to see if I could find any solutions. I found this thread.

The solution ended up that I needed to just remove the .git folder from the library while it resided in the vendor directory. (I actually just renamed it, but that seemed to do the same thing).




Monday, March 9, 2015

Python - Unable to find vcvarsall.bat

Problem:
Working on a quick prototype using maxmind, I wanted to use my new python skills. The geoip2 module looked like a good place to start, but I had to install the maxminddb module first. Trying to install that using pip gave me the following error:

UserWarning: Unknown distribution option: "bugtrack_url"
...
error: Unable to find vcvarsall.bat


Solution:
Looking online I found a couple SO questions that were exactly the same as mine. "How to I set vcvarsall.bat?" Turns out this is because when python builds the extension is wants to build it for Windows using the same C Runtime libraries python itself was built with. Several people indicated that the solution here was to install Visual C++ 2008 Express Edition (but seeing as it is now 2014, this was somewhat difficult to find).

To install these C Runtime libraries, download Visual C++ 2008 Express Edition.

Once you have it installed, you will need to restart your machine (or do something to allow the new environment variable of VS90COMNTOOLS to take).

Now you should be able to install your new extension using pip.

WordPress Slow Page Loads - JetPack

Problem:
My wife has a WordPress blog and over time everything has been slowing down until the site pretty much stopped working all together.

Solution:
Optimizing WordPress is a very large topic with many resources online. Following a couple different web site suggestions, I decided to start with the plugins as these are known to cause issues. My wife had about 30 installed. After deactivating all the plugins, things started working much better. I installed some plugins to assist with determining the plugin(s) causing the trouble.

After enabling plugins one-at-a-time and profiling the page loading using P3, I discovered that JetPack was causing the blog to have some major slow down. Little did I know, but many modules in JetPack were enabled by default and weren't being used. In fact, page load time went from 0.10 seconds to 1.5 seconds per page.

Disable Unused JetPack Modules (or JetPack)
If you click "Learn More" you will then see a new button called Deactivate. This button will turn off this module and will help to make your blog faster. I strongly suggest choosing to deactivate only the bare minimum to reduce unnecessary resource usage. If you can, do not use the JetPack plugin. Once the developers are able to increase their code performance, it will be worth looking at again.