question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] EROFS: read-only file system, mkdir '/opt/fonts/.fonts'

See original GitHub issue

Environment

  • chrome-aws-lambda Version: 5.5.0
  • puppeteer / puppeteer-core Version: 5.5.0
  • OS: Linux
  • Node.js Version: 12.x
  • Lambda / GCF Runtime: nodejs12.x

Expected Behavior

Using font should load the font

Current Behavior

AWS Lambda throws an error

"EROFS: read-only file system, mkdir '/opt/fonts/.fonts'"

Steps to Reproduce

const chromium = require('chrome-aws-lambda');

exports.handler = async (event, context, callback) => {
  let result = null;
  let browser = null;

  try {
    browser = await chromium.puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: await chromium.executablePath,
      headless: chromium.headless,
      ignoreHTTPSErrors: true,
    });

    await chromium.font('./fonts/Arial.ttf'); // Or any valid URL with a font in it

    let page = await browser.newPage();

    await page.goto(event.url || 'https://example.com');

    result = await page.title();
  } catch (error) {
    return callback(error);
  } finally {
    if (browser !== null) {
      await browser.close();
    }
  }

  return callback(null, result);
};

Possible Solution

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alixaxelcommented, Feb 7, 2021

@QAnders Apologies for only now getting to this. A few pointers:

  • The fonts will be placed under $HOME/.fonts/ (as it is usually in any other POSIX system).
    • On Lambda, $HOME is not set, and because it needs to be writable, it’s set to /tmp by this package.
  • The local fonts should be passed to font() with absolute paths (I will add this note to the README).
  • The fontconfig file will look for fonts under /tmp/aws/.fonts and /tmp/.fonts.
    • I will be adding support for /opt/.fonts in the fontconfig, which will make provisioning fonts via Layers easier.
0reactions
hoangtrieukdcommented, Jan 5, 2021
  1. I had changed HOME env /opt/fonts to /tmp and its working.
  2. I stored some fonts in layer for headless run. is that correct?
  3. “When AWS unpacks your Lambda it will find and “install” the fonts found in the fonts.config from the fonts directory automatically.” You mean i have to download all font i need. And store in fonts dir at root project => I think it will be increase lambda size to limit.
Read more comments on GitHub >

github_iconTop Results From Across the Web

NPM Error : Error: EROFS: read-only file system, mkdir '/npm'
The error means that you have no permission to install anything with npm at the path /npm . To verify this run npm...
Read more >
erofs: read-only file system, mkdir '/var/task/tmp' aws - You.com
The error seems self-explanatory: Error: EROFS: read-only file system, open '/var/task/assets/docs.zip'. /var/task is where your Lambda ... Favicon for ...
Read more >
How to fix "sudo: unable to open ... Read-only file system"?
Check if you have any faulty hardware.I got this error due to a hardisk loosening. Ran mount -o remount,rw / and it worked...
Read more >
How Do I Fix the "Read-only file system" Error When I Delete a ...
When you delete or modify a file on a Linux ECS, the message Read-only file system is displayed.The possible causes are as follows:The...
Read more >
"Read-only file system" when I try to touch in Mac OS Catalina
Copied directly from Apple KB - About the read-only system volume in macOS Catalina*. TL:DR With macOS Catalina, you can no longer store ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found