Net::SSH::AuthenticationFailed: Authentication failed for user vagrant@N.N.N.N

(This is a legacy post from the old website.)

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.


Need to get a bootable drive to install OS X (multiple versions suffer) and immediately met the following error?:

This copy of <Some OS X version> application can’t be verified. It may have been corrupted or tampered with during downloading.”

Missing ‘redcarpet’ gem for Markdown

(This is a legacy post from the old website.)

* Note, I’m not going to talk about how to make Redcarpet work. Instead I’m going to explain how to get Yard generating documentation again with a redcarpet alternative.

Maybe I’ve just been unlucky but I’ve had a number of run ins with
Redcarpet when using Yard over the years. I’ve learned that Yard can use
a number of markup-providers besides the Redcarpet gem.

For search purposes, here’s the verbage for my current scuffle with Redcarpet:

[error]: Missing ‘redcarpet’ gem for Markdown formatting. Install it with `gem install redcarpet`

To replace that redcarpet dependency:

1) generate a /.yardopts file if it doesn’t already exist. Any
configuration you provide in there will be picked up regardless if you
run yard directly or some Rake task calls yard with additional parameters.

2) Append a parameter to change the markup-provider.

--markup-provider <some markup-provider>

[image lost]

More options for a markup-provider beyond rdiscount are listed at: http://www.rubydoc.info/gems/yard/YARD/Templates/Helpers/MarkupHelper

3) Finally, ensure your Gemfile lists your new markup-provider.

Gem::FilePermissionError: You don’t have write permissions for the /Users//.rvm/gems/… directory.

(This is a legacy post from the old website.)

Getting the following error?:

Gem::FilePermissionError: You don’t have write permissions for the /Users/<username>/.rvm/gems/… directory.

Probably installed something under sudo. Fix the ownership of your RVM directory.

sudo chown -R <username> ~/.rvm

Your VM has become “inaccessible.”

(This is a legacy post from the old website.)

If you’ve deleted a virtual machine file still referenced by one of your
projects, you’ll run into the following error when you try and
instantiate the VM via vagrant up.

Your VM has become “inaccessible.” Unfortunately, this is a critical error with VirtualBox that Vagrant can not cleanly recover from. Please open VirtualBox and clear out your inaccessible virtual machines or find a way to fix them.

Vagrant creates a hidden folder within your project directory named .vagrant with files that refer to specific VM IDs.

[image lost]

Simply delete the .vagrant folder within your project and rerun vagrant up. Vagrant will rebuild the .vagrant directory with the correct files and ID.

For giggles, here’s a Github issue page regarding this with a few more details.

Conditionally run QUnit tests based on browser.

(This is a legacy post from the old website.)

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).

[image lost]

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.

Can not find compiler and ‘make’ tool – make sure Xcode and/or Command Line Tools are installed.

(This is a legacy post from the old website.)

Running afoul of the following error when trying to install rubies with RVM despite having installed Xcode?

Can not find compiler and ‘make’ tool – make sure Xcode and/or Command Line Tools are installed.

With newer versions of Xcode the command line tools RVM expects are not automatically installed alongside Xcode.

Open Xcode and navigate to: Xcode > Preferences > Downloads and click Install for Command Line Tools.

There was an error while executing `VBoxManage`,

(This is a legacy post from the old website.)

I’ve found I occasionally run into an odd Vagrant error every now and then:

There was an error while executing
`VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.
Command: [“hostonlyif”, “create”]

For me, this sometimes happens when I try to re-instantiate a virtual
machine after my laptop’s battery has died and OSX has attempted to
restore state. Other people seem to encounter this error under different
conditions; even immediately after installing Vagrant and attempting to
spin up a virtual machine for the first time.

Run the following command to bounce VirtualBox:

sudo /Library/StartupItems/VirtualBox/VirtualBox restart

and now running:

vagrant up

should go off without a hitch.

Python 3 Class Hiccup

(This is a legacy post from the old website.)

Today I was trying to implement the observer pattern in Python,
updating the observer with property methods, but my code was acting
wonky. Specifically, my setter wasn’t calling a method it was supposed
to be calling.

TL;DR version


If properties aren’t functioning like they should, ensure that your
classes are inheriting from object. Your classes don’t automatically
inherit from object (or the featured base class) in Python like in some
other languages (in python this is for the sake of backwards
compatibility). Use:

class MyClass(object):

instead of

class MyClass:

Long version


Here’s the basic observer pattern in Python (Notice not inheriting from object):

class ObjectOfInterest():
  def __init__(self):
    self.observers = []
    self._name = None

  def register_observer(self, observer):
    self.observers.append(observer)

  def _get_name(self):
    return self._name

  def _set_name(self, name):
    self._name = name
    self._update_observers()

  # I prefer this method of setting up properties over the @ syntax
  name = property(_get_name, _set_name)

  def _update_observers(self):
    for observer in self.observers:
    observer.update()

class Observer():
  def __init__(self, thing_to_watch):
    self.thing_to_watch = thing_to_watch
    self.thing_to_watch.register_observer(self)

  def update(self):
    print("updated.")

Pretty straight forward, right? However, _update_observers()
is never called. You will not see “updated.” printed to the console.
Everything seems like it’s working; the value of name is being updated.
So WTF?!

thing_to_watch = ObjectOfInterest()
observer = Observer(thing_to_watch)

print(thing_to_watch.name) # None

thing_to_watch.name = 'Bilbo'
print(thing_to_watch.name) # Bilbo

thing_to_watch.name = 'Frodo'
print(thing_to_watch.name) # Frodo

Remembering to inherit from object gets properties working right. Here
again is the code with output but this time my classes do inherit from
object and everything is right with the world.

thing_to_watch = ObjectOfInterest()
observer = Observer(thing_to_watch)

print(thing_to_watch.name) # None

thing_to_watch.name = 'Bilbo' # updated.
print(thing_to_watch.name) # Bilbo

thing_to_watch.name = 'Frodo' # updated.
print(thing_to_watch.name) # Frodo

This is a sloppy mistake that had me guessing for a good bit. Nothing was out of place and yet my results were borked.


I’ve found I occasionally run into an odd Vagrant error every now and then:

Failing Ubuntu 12.04 Install

(This is a legacy post from the old website.)

During a Ubuntu 12.04 install your screen may go blank
(purple) part way during the installation process. For me, this always
came directly after setting my hostname.

The likely fix is to run the installation with nomodeset option. For
details see the How to set NOMODESET option discussion. The short version looks like this:

  • From the Ubuntu menu > F6 > Select nomodeset
  • From the Ubuntu menu > Install Unbuntu

Hopefully the rest of the install process is uneventful.