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

bun build --compile does not produce a standalone executable - still depends on external files #14676

Open
guest271314 opened this issue Oct 19, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@guest271314
Copy link
Contributor

What version of Bun is running?

1.1.31-canary.58

What platform is your computer?

Linux 5.15.0-43-generic x86_64 x86_64 (7283453)

What steps can reproduce the bug?

bun install npm
bun build node_modules/npm/bin/npm-cli.js --compile --bytecode --outfile=bun-npm

Run the executable without removing the nodule_modules directory, works as expected.

bun-npm --help
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term>
npm help npm       more involved overview

All commands:

    access, adduser, audit, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    help-search, hook, init, install, install-ci-test,
    install-test, link, ll, login, logout, ls, org, outdated,
    owner, pack, ping, pkg, prefix, profile, prune, publish,
    query, rebuild, repo, restart, root, run-script, sbom,
    search, set, shrinkwrap, star, stars, start, stop, team,
    test, token, uninstall, unpublish, unstar, update, version,
    view, whoami

Specify configs in the ini-formatted file:
    /home/user/.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

[email protected] /home/user/bin/node_modules/npm

Remove the node_modules folder

rm -rf node_modules

What is the expected behavior?

The standalone executable shoule be standalone, without looking for the module source files of the executable on the machine.

What do you see instead?

Run the executable again, without node_modules directory on the machine, and the executable does not work as expected. Can't find a module in node_modules that doesn't exist.

bun-npm --help
error: Cannot find module "/home/user/bin/node_modules/npm/lib/cli/entry.js" from "/$bunfs/root/bun-npm"
      at syntaxErrorHandler (/$bunfs/root/bun-npm:287:16)

Additional information

Compare compiling to a standalone executable with Deno

deno add npm:npm
deno compile -A --output=deno-npm node_modules/npm/bin/npm-cli.js

Run the executable to make sure it works

deno-npm --help
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term>
npm help npm       more involved overview

All commands:

    access, adduser, audit, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    help-search, hook, init, install, install-ci-test,
    install-test, link, ll, login, logout, ls, org, outdated,
    owner, pack, ping, pkg, prefix, profile, prune, publish,
    query, rebuild, repo, restart, root, run-script, sbom,
    search, set, shrinkwrap, star, stars, start, stop, team,
    test, token, uninstall, unpublish, unstar, update, version,
    view, whoami

Specify configs in the ini-formatted file:
    /home/user/.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

[email protected] /tmp/deno-compile-deno-npm/bin/node_modules/.deno/[email protected]/node_modules/npm

Remove node_modules, and just be sure remove /tmp/deno-compile-deno-npm/bin/node_modules/.deno/[email protected]/node_modules/npm to see if the standalone executable produced by deno still works as expected.

rm -rf node_modules /tmp/deno-compile-deno-npm/bin/node_modules/.deno/[email protected]/node_modules/npm /tmp/deno-compile-deno-npm
deno clean

Run the executable again

deno-npm
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term>
npm help npm       more involved overview

All commands:

    access, adduser, audit, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    help-search, hook, init, install, install-ci-test,
    install-test, link, ll, login, logout, ls, org, outdated,
    owner, pack, ping, pkg, prefix, profile, prune, publish,
    query, rebuild, repo, restart, root, run-script, sbom,
    search, set, shrinkwrap, star, stars, start, stop, team,
    test, token, uninstall, unpublish, unstar, update, version,
    view, whoami

Specify configs in the ini-formatted file:
    /home/user/.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

[email protected] /tmp/deno-compile-deno-npm/bin/node_modules/.deno/[email protected]/node_modules/npm

The standalone executable produced by deno compile still works.

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

No branches or pull requests

1 participant