Category Archives: Uncategorized

Capistrano authentication failure on a Vagrant VM

I was having issues getting Capistrano to SSH into a Vagrant VM. I could shell in myself but Capistrano always returned the following error:

connection failed for: 33.33.33.33 (Net::SSH::AuthenticationFailed: Authentication failed for user vagrant@33.33.33.33)

Note: 33.33.33.33 is my private network set up in the vagrantfile.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = 'precise32'
    config.vm.host_name = 'virtualmachine'
    config.vm.network "private_network", :ip => '33.33.33.33'
    config.vm.provider :virtualbox do |v|
        v.customize ["modifyvm", :id, "--memory", 4096]
    end
end

For me, the problem only occurred with the local VM. Capistrano had no problems interacting with remove web servers via SSH.

Try changing the version of the net-ssh gem in use per this SO post. For me, locking net-ssh to 2.8.1 solved the issue. There were some Stackoverflow comments suggesting the bug reappears in newer releases.

Posted in Uncategorized | Leave a comment

Mount a filesystem over SSH on OSX (sshfs)

1) Download & install FUSE for OSX.

2) Create an empty local folder to act as a mount point.

3) Mount the filesystem over SSH.

Syntax:

sshfs <username>@<IP or URL>:<remote path> <path to local mount point>

Example:

sshfs bilbo@theshire.com:/var/www/bagend ~/Desktop/mnt

I’m not a huge fan of using Vim or Nano/Pico for lengthy editing sessions on remote servers. This allows me to use Sublime Text (or whatever your editor of choice). I’ve not encountered any latency issues and it’s much smoother than forwarding X (which I never have installed on a webserver anyway).

 

Posted in Code, Linux, OS X, Uncategorized | Leave a comment

Skipping tests in specific browsers or Phantom.js / Grunt.js build scripts

I’m working on a project that I’ve built a very comprehensive Javascript test suite for with QUnit. I run tests a few times in a few different ways before subjecting the world to my code.

First I load the QUnit test page in multiple browsers to ensure I’m not going to be bitten by a cross-browser compatibility bug (IE). 

qunit

Afterward, when I run my Grunt build script to check, concatenate, and minify my JS, it re-runs those tests before concatenating, after concatenating, and finally on the minified version as well.

Occasionally I run into some false positives (failed tests) that are tied to some browser quirk like Chrome not allowing file cookies (unable to set cookies when the URL is local: file:///…) or the fact that PhantomJS isn’t a true browser so it isn’t able to handle cookies gracefully. Don’t skip writing tests for troublesome bits, instead just conditionally skip those tests based on user agents.

For example, I have two test helpers in a file test_helpers.js:

var helpers = {
	// Determine if tests are running in Chrome
	is_chrome: navigator.userAgent.toLowerCase().indexOf('chrome') > -1,

	// Determine if tests are running in PhantomJS.
	is_phantom: navigator.userAgent.toLowerCase().indexOf('phantom') > -1,
};

I include test_helpers.js file into my QUnit test page(s). Then I wrap any tests that succumb to environment issues in an if statement:

test('Session creates a session & cookie upon instantiation (TEST SKIPPED IN CHROME! WILL NOT PASS).', function(){
	if(!helpers.is_chrome && !helpers.is_phantom){
		// Test that runs only outside of Chrome and Phantom.js
	}
});

My troublesome QUnit tests will run in all clients except those I’ve explicitly avoided. My tests run green in both Chrome and my Grunt build script.

grunt_qunit

Posted in Code, Grunt.js, JavaScript, QUnit.js, Uncategorized | Leave a comment

Xcode can’t be installed because Mac OS X Version N or later is required.

So, say you need Xcode installed (or updated) because you need GCC and/or other development support tools on your OS X 10.7 machine. So, you launch App Store expecting to install (or update) Xcode easily enough but are met with one of two messages telling you that you’re SOL.

no-install
No install
no-update
No update

At this point it seems like you’re forced into paying to upgrade OS X but there’s an alternative. Albeit, not an obvious one. You can download older version of Xcode if you have or create an Apple developer account. The direct link to the Xcode downloads page is: https://developer.apple.com/downloads/index.action?q=xcode

Note: If you’re running OS X 10.7 you’ll need (as of this writing) to install Xcode 4.6.3 as Xcode 5 requires OS X 10.8.

xcode download page

It just works, right?

Posted in Code, OS X, Uncategorized | Leave a comment