What should be the path to the file while using #attached in a custom_module_block_view()? I have created a custom module and was trying to add javascript file to a block using #attached method which was described here. I am confused with the Path/to/file as I have tried to give a full path which is "/var/www/html/sites/all/modules/custom_module/js/file.js". and shorter path "js/file.js"

but it doesn't load.

It just say file_get_contents("/var/www/html/sites/all/modules/custom_module/js/file.js"): unable to load, no such file or folder present /var/www/html/common.inc .....

Why I am getting the file_get_contents error when I am not using this method?
You should use drupal_get_path() function to construct the path of your asset file (in your case the JS file).

To include the YOUR_MODULE.js file which sits in a subfolder js, part of your custom module

$block = array
(
    'subject' =&gt; t('My block title'),
    'content' =&gt; array(
        '#markup' =&gt; '&lt;p&gt;' . t('This is some text that will go in the block.') . '&lt;/p&gt;',
        '#attached' =&gt; array(
            'js' =&gt; array(drupal_get_path('module', 'YOUR_MODULE_NAME') . '/js/YOUR_MODULE.js'),
        ),
    ),
);