Chrome Script/Extension installation error: Could not read source file

This is a solution to the issue that I faced today while installing a javascript file from as an extension into google chrome (Yes, Chrome supports installing greasemonkey javascripts as extensions). I had already installed this script once into my browser earlier but when I tried installing it again today, it started giving me a weird error “Could not read source file”. I tried all possible means, like putting it on a different server, installing from local disk, changing versions, deleting all cache, etc but still the issue persisted.

Finally looking into the source code of the chromium browser svn repository, I got a clue. What google chrome does when you install a script as installation is that it first downloads the script, then it calls a function ConvertUserScriptToExtension to convert the script into a google chrome compatible script and then installs it. Now, since I had already installed this script once, I found that the script was already existing in my downloads directory, so while downloading chrome renames it to (1).js (i.e., appends a number to it to distinguish from the original file). But it seems like that the path sent to the conversion function still uses the original name/path and it somehow finds that the older file is not the downloaded one but also doesn’t know which is the current downloaded one and hence fails with an error “Could not read source file”.

Solution: Pretty simple. Just delete the original file present in your download directory and then try installing the script and it will install fine :)

See also