Skip to content

Cross-compiling from Linux to macOS produces non-functional binaries #183

@tasshi-me

Description

@tasshi-me

What version of pkg are you using?

6.9.0

What version of Node.js are you using?

20.19.5, 22.20.0, 24.10.0

What operating system are you using?

macOS 15

What CPU architecture are you using?

arm64

What Node versions, OSs and CPU architectures are you building for?

linux-x64,win-x64,macos-arm64

Describe the Bug

When I build a macOS binary on Ubuntu using pkg, the build succeeds without any errors.
However, the resulting executable doesn’t run the packaged app — instead, it starts a plain Node.js process.

I checked #87 and #181, but couldn’t determine whether they are related.

Expected Behavior

The packaged application should start normally, as it does when built natively on macOS.

To Reproduce

# Step 1. Build executables for macOS on a Linux x64 machine
echo 'console.log("Hello, World!");' > index.js
npx @yao-pkg/pkg@6.9.0 --sea index.js -t macos-x64,macos-arm64
# => executables are generated (index-arm64, index-x64)

# Step 2. Copy executables (index-arm64, index-x64) to a macOS machine

# Step 3. Run executables on a macOS machine (I checked on Apple M1)
./index-arm64
# => Node.js REPL starts
# Welcome to Node.js v22.20.0.
# Type ".help" for more information.
# >
# Error: Could not open history file.
# REPL session history will not be persisted.
# >

./index-x64
# => Node.js REPL starts
# Welcome to Node.js v22.20.0.
# Type ".help" for more information.
# >
# Error: Could not open history file.
# REPL session history will not be persisted.
# >

Repro Repo

A minimal reproduction using CI is available here:
https://github.com/tasshi-playground/repro-pkg-cross-platform-issue

Build on linux
Built on macos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions