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

Installation failed on node-llama-cpp postscript #1503

Open
salacoste opened this issue Dec 27, 2024 · 8 comments
Open

Installation failed on node-llama-cpp postscript #1503

salacoste opened this issue Dec 27, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@salacoste
Copy link

installation process stucks during quick start guide steps, installation node-llama-cpp failed and then it stuck on node_modules/@discordjs/opus: Running install script...

Used node 23.3.0

The commit version is 77b5b7d v0.1.7-alpha.1

77b5b7d v0.1.7-alpha.1 ● ?  pnpm install --no-frozen-lockfile  ✔  10161  21:41:18
Scope: all 47 workspace projects
client |  WARN  Installing a dependency from a non-existent directory: /Users/r2d2/Documents/Code_Projects/eliza/client/@tanstack/router-plugin/vite
packages/adapter-redis |  WARN  deprecated @types/[email protected]
packages/client-discord |  WARN  deprecated @discordjs/[email protected]
packages/client-slack |  WARN  deprecated @slack/[email protected]
packages/core |  WARN  deprecated @types/[email protected]
packages/plugin-node |  WARN  deprecated @cliqz/[email protected]
packages/plugin-story |  WARN  deprecated @pinata/[email protected]
packages/plugin-trustdb |  WARN  deprecated @types/[email protected]
 WARN  34 deprecated subdependencies found: @cliqz/[email protected], @cliqz/[email protected], @cliqz/[email protected], @humanwhocodes/[email protected], @humanwhocodes/[email protected], @motionone/[email protected], @simplewebauthn/[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
 WARN  Issues with peer dependencies found
client
├─┬ @vitejs/plugin-react 4.3.3
│ └── ✕ unmet peer vite@"^4.2.0 || ^5.0.0": found 0.0.0
├─┬ vite-plugin-top-level-await 1.4.4
│ └── ✕ unmet peer vite@>=2.8: found 0.0.0
└─┬ vite-plugin-wasm 3.3.0
└── ✕ unmet peer vite@"^2 || ^3 || ^4 || ^5": found 0.0.0

packages/client-lens
└─┬ @lens-protocol/client 2.2.0
└─┬ @lens-protocol/gated-content 0.5.1
└─┬ @lit-protocol/node-client 2.1.62
├─┬ @walletconnect/ethereum-provider 2.17.3
│ └─┬ @walletconnect/modal 2.7.0
│ ├─┬ @walletconnect/modal-core 2.7.0
│ │ └─┬ valtio 1.11.2
│ │ ├── ✕ missing peer react@>=16.8
│ │ └─┬ use-sync-external-store 1.2.0
│ │ └── ✕ missing peer react@"^16.8.0 || ^17.0.0 || ^18.0.0"
│ └─┬ @walletconnect/modal-ui 2.7.0
│ └─┬ @walletconnect/modal-core 2.7.0
│ └── ✕ missing peer react@>=16.8
└─┬ @lit-protocol/auth-browser 2.1.62
└─┬ @walletconnect/ethereum-provider 2.17.3
└── ✕ missing peer react@>=16.8
Peer dependencies that should be installed:
react@">=16.8.0 <17.0.0 || >=17.0.0 <18.0.0 || >=18.0.0 <19.0.0"

packages/core
└─┬ @langchain/core 0.3.26
└─┬ zod-to-json-schema 3.24.1
└── ✕ unmet peer zod@^3.24.1: found 3.23.8

packages/plugin-0g
└─┬ @0glabs/0g-ts-sdk 0.2.1
└── ✕ unmet peer [email protected]: found 6.13.4

packages/plugin-goat
├─┬ @goat-sdk/wallet-viem 0.1.3
│ └── ✕ unmet peer @goat-sdk/[email protected]: found 0.3.8
└─┬ @goat-sdk/plugin-coingecko 0.1.4
├── ✕ unmet peer @goat-sdk/[email protected]: found 0.3.8
└── ✕ unmet peer [email protected]: found 2.21.53

Packages: +4705
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 4088, reused 3922, downloaded 0, added 4705, done
node_modules/@swc/core: Running postinstall script...
node_modules/canvas: Running install script...
node_modules/node-llama-cpp: Running postinstall script, failed in 1.6s
node_modules/node-llama-cpp postinstall$ node ./dist/cli/cli.js postinstall
└─ Failed in 1.6s at /Users/r2d2/Documents/Code_Projects/eliza/node_modules/node-llama-cpp
node_modules/@discordjs/opus: Running install script...

@salacoste salacoste added the bug Something isn't working label Dec 27, 2024
@salacoste
Copy link
Author

i was able sucessfully installed this release on old intel based mac, but struggle to make it works on Apple silicon (that's the one difference between these 2 systems, the rest like node version, pnpm and the rest were the same).

pnpm 9.15.1 were used for both, node 23+.

I'm keen to make it work on my main mac (Apple silicon), still curious if we can solve it.

@salacoste
Copy link
Author

i have researched the question about cpp and found out the following:

npx --no node-llama-cpp inspect gpu

(node:46665) ExperimentalWarning: CommonJS module /Users/r2d2/.nvm/versions/node/v23.3.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /Users/r2d2/.nvm/versions/node/v23.3.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
OS: macOS 22.3.0 (x64)
Node: 23.3.0 (x64)
TypeScript: 5.6.3
node-llama-cpp: 3.1.1

Metal: not supported by llama.cpp on Intel Macs
[1]    46665 illegal hardware instruction  npx --no node-llama-cpp inspect GPU

I have M2 Chip

@bkotrys
Copy link

bkotrys commented Dec 30, 2024

I have exactly the same problem

@Noveleader
Copy link

I have a M4 machine and it works perfectly on my device with pnpm version being 9.15.0 and node version being 23.3.0. I was not able to reproduce the problem here.

@bkotrys
Copy link

bkotrys commented Dec 30, 2024

The problem seems to be explicitly related to M2 machines.

@haskell-monad
Copy link

have you found a solution?

@salacoste
Copy link
Author

image_2025-01-01_13-45-03
guys helped me to catch an initial root cause of the problem, nvm installs x64 versions of nodeJs to arm system.
They work fine unless some certain cpp methods and calls which were caused by this mismatch.

You need to check that you have the proper node version in your system otherwise

node -e "console.log(process.platform, process.arch)"                   
darwin arm64

I have reinstalled nodejs package natively in the system, remove nvm usage as it didn't support arm version of node.

but later I encountered with bunch of problems the package compatibility as some of them support only x64 architecture: like esbuild, rollup, sharp...

I was able to fix them by changing dependencies in package.json(s) on arm supported versions or sometimes just updated their versions up to the most recent.

But I'm stuck at sharp package with the following logs:

npm start      
 WARN  Unsupported engine: wanted: {"node":"23.3.0"} (current: {"node":"v23.5.0","pnpm":"9.15.1"})

> eliza@ start /Users/r2d2/Documents/Code_Projects/eliza
> pnpm --filter "@elizaos/agent" start --isRoot

.                                        |  WARN  Unsupported engine: wanted: {"node":"23.3.0"} (current: {"node":"v23.5.0","pnpm":"9.14.4"})
docs                                     |  WARN  Unsupported engine: wanted: {"node":"23.3.0"} (current: {"node":"v23.5.0","pnpm":"9.14.4"})

> @elizaos/[email protected] start /Users/r2d2/Documents/Code_Projects/eliza/agent
> node --loader ts-node/esm src/index.ts "--isRoot"

(node:8415) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8415) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
[ElizaLogger] Initializing with:
            isNode: true
            verbose: false
            VERBOSE env: undefined
            NODE_ENV: undefined
        
 ℹ INFORMATIONS
   Loading embedding settings: 
   {"OLLAMA_EMBEDDING_MODEL":"mxbai-embed-large"} 

 ℹ INFORMATIONS
   Loading character settings: 
   {"ARGV":["/usr/local/bin/node","/Users/r2d2/Documents/Code_Projects/eliza/agent/src/index.ts","--isRoot"],"CWD":"/Users/r2d2/Documents/Code_Projects/eliza/agent"} 

 ℹ INFORMATIONS
   Parsed settings: 
   {"USE_OPENAI_EMBEDDING_TYPE":"undefined","USE_OLLAMA_EMBEDDING_TYPE":"undefined","OLLAMA_EMBEDDING_MODEL":"mxbai-embed-large"} 

using deprecated parameters for the initialization function; pass a single object instead
/Users/r2d2/Documents/Code_Projects/eliza/node_modules/sharp/lib/sharp.js:113
  throw new Error(help.join('\n'));
        ^

**_Error: Could not load the "sharp" module using the darwin-arm64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=darwin --cpu=arm64 sharp_**
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/Users/r2d2/Documents/Code_Projects/eliza/node_modules/sharp/lib/sharp.js:113:9)
    at Module._compile (node:internal/modules/cjs/loader:1740:14)
    at Object..js (node:internal/modules/cjs/loader:1905:10)
    at Module.load (node:internal/modules/cjs/loader:1474:32)
    at Function._load (node:internal/modules/cjs/loader:1286:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1496:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/Users/r2d2/Documents/Code_Projects/eliza/node_modules/sharp/lib/constructor.js:10:1)

Node.js v23.5.0
/Users/r2d2/Documents/Code_Projects/eliza/agent:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @elizaos/[email protected] start: `node --loader ts-node/esm src/index.ts "--isRoot"`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

I tried different options and things to come over the problem but was unsuccessful so far.

Any ideas on that though?

by the way,it worth to make the package list more compatible across different platforms. some versions were used old one which doesn't have such compatability.

@AIFlowML
Copy link
Contributor

AIFlowML commented Jan 3, 2025

Hello mate.
Are you usding latst version of ElizaOS and the dependencies ?
Let us know to dig deeper.

Here some tips

1. TLDR (Executive Summary)

  • Issue Essence: Installation failure during node-llama-cpp's postinstall script.
  • Root Cause: Conditional logic in postinstall script fails on unsupported platforms, compounded by unmet peer dependencies and deprecated packages.
  • Solution Approach: Modify postinstall script, resolve dependencies, and ensure platform compatibility.
  • Impact Assessment: Prevents installation failures and ensures smooth setup on supported platforms.

2. Quick Resolution Path

  • Immediate Steps:

    1. Modify the postinstall script to handle unsupported platforms gracefully.
    2. Install or update unmet peer dependencies (vite, react, zod, ethers, @goat-sdk/core).
    3. Update or replace deprecated packages.
  • Exact File Locations and Line Numbers:

    • File: packages/plugin-node/scripts/postinstall.js
    • Lines: Modify the conditional logic to include more platforms or skip installation gracefully.
  • Required Code Changes:

    import os from "os";
    const platform = os.platform();
    
    if (
        platform === "linux" &&
        !(os.release().includes("ubuntu") || os.release().includes("debian"))
    ) {
        console.log(
            "Skipping playwright installation on unsupported platform:",
            platform
        );
    } else {
        const { execSync } = await import("child_process");
        try {
            execSync("npx playwright install-deps && npx playwright install", {
                stdio: "inherit",
            });
        } catch (error) {
            console.error("Playwright installation failed:", error);
        }
    }
  • Validation Commands:

    pnpm install --no-frozen-lockfile
  • Rollback Procedures:

    • Revert changes to postinstall.js.
    • Reinstall previous versions of dependencies if issues arise.

3. Comprehensive Solution

  • Detailed Technical Analysis:

    • The postinstall script fails on unsupported platforms due to conditional logic. Unmet peer dependencies and deprecated packages further complicate the installation.
  • Step-by-Step Implementation:

    1. Modify postinstall Script: Update the script to handle more platforms or skip installation gracefully.
    2. Resolve Peer Dependencies: Install or update vite, react, zod, ethers, and @goat-sdk/core.
    3. Update Deprecated Packages: Replace or update deprecated dependencies.
    4. Verify Node.js Compatibility: Ensure Node.js 23.3.0 is compatible or switch to a stable LTS version.
  • Dependencies and Side Effects:

    • Ensure all dependencies are compatible with the modified script and updated packages.
  • Configuration Changes:

    • Update package.json to reflect new dependency versions.
  • Environment Requirements:

    • Supported platforms: Ubuntu, Debian, or other specified platforms.
  • Database Changes:

    • No database changes required.
  • Service Impacts:

    • Ensures smooth installation and setup of node-llama-cpp and related packages.

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

No branches or pull requests

6 participants
@haskell-monad @bkotrys @salacoste @Noveleader @AIFlowML and others