Month: September 2015

NPM workaround for EROFS error

On my Virtualbox with lubuntu, upon running npm install I encountered problems with installing some packges.

npm ERR! rofs EROFS, symlink '../rimraf/bin.js'
npm ERR! rofs This is most likely not a problem with npm itself
npm ERR! rofs and is related to the file system being read-only.
npm ERR! rofs 
npm ERR! rofs Often virtualized file systems, or other file systems
npm ERR! rofs that don't support symlinks, give this error.

As the error explains, this probably has to do with the filesystem being virtualized. This was also in a shared folder with the host machine.

To work around this, use the –no-bin-link command option to prevent npm from attempting to create symbolic links. As a result, the commands of the package will not be available in _node_modules/.bin_. But it will still be available from the bin folder of the package itself.

Leave a Comment

Set charset on PDO connection with mysql in PHP

When using PDO to connect to MySQL it is wise to explicitly set the character set to utf8 (of course, only when using utf8 is the charset). In the MySQL or MySQLi extension I would normally execute the query SET NAMES utf8 to set it.

In PDO the charset can be specified in the connection string:

$conn = new PDO("mysql:host=$host;dbname=$db;charset=utf8", $user, $pass);

The charset option is only used since PHP 5.3.6, so take this into account when running an older version of PHP. In that case you should run the following statement after constructing the PDO object:

$conn->exec('SET NAMES utf8');

But you should’nt be running such an old version of PHP anyway.

Leave a Comment

Google Data redirectUri required

In a piece of code where authentication/authorization for Youtube was done, I only setting the redirect_uri in the piece of code where the logging in was done, using createAuthUrl(). This value is the location to redirect to when the authorization is completed and the user is redirected back to the invoking website.

In subsequent requests, when attempting to upload a video, the Client was throwing errors. It was not immediately clear what was wrong, but it turns out that even for non-authentication requests the setRedirectUri() function must be specified for the API to work.

Leave a Comment