Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: libuuid.so.1: cannot open shared object file: No such file or directory #2046

Open
RashiqAzhan opened this issue May 13, 2024 · 2 comments
Assignees
Labels
bug Something isn't working triage Issue needs triage

Comments

@RashiqAzhan
Copy link

What happened?

node-canvas dependency breaks the entire node project. node index.js is broken.

I tired following the solutions here to install libuuid manually but to no avail.

Terminal Output:

node:internal/modules/cjs/loader:1473
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libuuid.so.1: cannot open shared object file: No such file or directory
    at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (.../canvas_github_issue/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v20.11.1

Expected output:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nOy9Z3BlaX7e93vf98SbI3BxAXQD3Y2O0xN68szOZi43kGJcUpQDXUWJlF2WqlRll1NJH1xOZbssFWWbFCVZtkRKNJeSxWTuape7s9zZMGkndk/nBOAiAzeee096X3846B7yI8s9NcYYT1dX30J3nT7Ae57zz88fDnGIQxziEIc4xCEOcYhDHOIQfyEYg/iw7+EQH018JB6sf/k7v/ol3/P+6fbWdufX/v7/0bm7utHR2qwrKTqkphOhO/3dQWcC60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gg4eHQyDhFK4ZCQEwIlwVg2FSXw8976L/...

The project is working fine inside docker with which the portion shown under expected output was generated.

Steps to reproduce

  1. Get any project that uses node-canvas dependency breaks the entire node project. node index.js is broken.

MWE:
index.js

// Source: https://github.com/Automattic/node-canvas?tab=readme-ov-file#quick-example
const { createCanvas, loadImage } = require('canvas')
const canvas = createCanvas(200, 200)
const ctx = canvas.getContext('2d')

// Write "Awesome!"
ctx.font = '30px Impact'
ctx.rotate(0.1)
ctx.fillText('Awesome!', 50, 100)

// Draw line under text
var text = ctx.measureText('Awesome!')
ctx.strokeStyle = 'rgba(0,0,0,0.5)'
ctx.beginPath()
ctx.lineTo(50, 102)
ctx.lineTo(50 + text.width, 102)
ctx.stroke()

// Draw cat with lime helmet
loadImage('https://images-assets.nasa.gov/image/AFRC2024-0067-40/AFRC2024-0067-40~orig.jpg').then((image) => {
  ctx.drawImage(image, 50, 0, 70, 70)

  console.log('<img src="' + canvas.toDataURL() + '" />')
})

package.json

{
  "name": "canvas_github_issue",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "canvas": "^2.11.2"
  }
}

2.1. Devbox route to produce the error.

devbox shell

npm i

node index.js

2.2. Docker route produces no errors.

docker run --rm -it \
      -w /usr/src/app \
      -v .:/usr/src/app \
      node:20.11.1-slim bash

node index.js

Command

shell

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.1/.schema/devbox.schema.json",
  "packages": [
    "[email protected]",
    "libuuid@latest"
  ],
  "env": {
    "LD_LIBRARY_PATH": "pkgs.lib.makeLibraryPath [pkgs.libuuid];"
  },
  "shell": {
    "init_hook": ["echo 'Welcome to devbox!' > /dev/null"],
    "scripts": {
      "test": ["echo \"Error: no test specified\" && exit 1"]
    }
  }
}

Devbox version

0.10.5

Nix version

2.18.1

What system does this bug occur on?

Linux (x86-64)

Debug logs

No response

@RashiqAzhan RashiqAzhan added bug Something isn't working triage Issue needs triage labels May 13, 2024
@Lagoja
Copy link
Contributor

Lagoja commented May 16, 2024

I'm having trouble reproducing this exactly, but here are a few suggestions that I think will help:

  1. It looks like the libuuid.so1 file is bundled with the dev output of the libuuid package. You can add this output by running devbox add libuuid --outputs=out,dev

  2. Devbox automatically symlinks any libraries, binaries, and files that it installs to $DEVBOX_PACKAGES_DIR. If you need your node packages to access those libraries, you can try adding export LD_LIBRARY_PATH=$DEVBOX_PACKAGES_DIR/lib:$LD_LIBRARY_PATH to your devbox.json's init_hook. This will ensure that the libraries Devbox installs are in your LD_LIBRARY_PATH while still leaving the rest of LD_LIBRARY_PATH intact

@Lagoja Lagoja self-assigned this May 16, 2024
@Lagoja
Copy link
Contributor

Lagoja commented May 17, 2024

Here is an example devbox.json that I got to work on https://devbox.sh:

https://github.com/Lagoja/node-canvas/blob/main/devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.1/.schema/devbox.schema.json",
  "packages": {
    "libuuid": {
      "version": "latest",
      "outputs": ["lib"]
    },
    "nodejs":     "20.11",
    "pkg-config": "latest",
    "pixman":     "latest",
    "cairo": {
      "version": "latest",
      "outputs": ["dev"]
    },
    "freetype": {
      "version": "latest"
    },
    "glib": {
      "version": "latest",
      "outputs": ["out"]
    }
  },
  "env": {"LD_LIBRARY_PATH": "$DEVBOX_PACKAGES_DIR/lib"},
  "shell": {
    "init_hook": ["echo 'Welcome to devbox!' > /dev/null"],
    "scripts": {
      "test": ["echo \"Error: no test specified\" && exit 1"]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs triage
Development

No branches or pull requests

2 participants