NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.8k forks source link

vscode, vscodium: `--help` errors out #292182

Open ShamrockLee opened 7 months ago

ShamrockLee commented 7 months ago

Describe the bug

VSCode/VSCodium code --help and codium --help print error messages instead of help message, and exit with status 133.

$ codium --help

#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804 (see crbug.com/1201626)
#
#
#
#FailureMessage Object: 0x7ffc997a60a0
/nix/store/d2wi97gdnpcqa731a7lq87v2s7x8c7k5-vscodium-1.84.2.23317/bin/.codium-wrapped: line 63:  8883 Trace/breakpoint trap   (core dumped) ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@

$ echo "$?"
133
$ code --help

#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804 (see crbug.com/1201626)
#
#
#
#FailureMessage Object: 0x7ffc9a7e3770
/nix/store/mhm5ccj9mcqxqh98fm5zfqasb35ppfd5-vscode-1.84.2/bin/.code-wrapped: line 63: 13385 Trace/breakpoint trap   (core dumped) ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
$ echo $?
133

Steps To Reproduce

Steps to reproduce the behavior:

  1. install vscode/vscodium or run from nix-shell.
  2. Run code --help or codium --help.
  3. See error.

Expected behavior

code --help and codium --help prints their command-line help message, as shown in the following web page: https://code.visualstudio.com/docs/editor/command-line

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

@Synthetica9 @bobby285271 @ludovicopiero

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.0-rc2, NixOS, 23.11 (Tapir), 23.11.20231212.cf28ee2`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/store/ch82i0ka6gw80amas17rfy392yyidpsf-source`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 7 months ago

I can't reproduce the error on nixos-unstable or nixos-23.11; can you try updating your channels and rebuilding, then trying again?

ShamrockLee commented 7 months ago

This is the flake-baesd reproduction on the latest commit of Nixpkgs:

nixpkgs_timeshift (9289da8) [$]
❯ nix run .#vscodium -- --help
Invalid array length

nixpkgs_timeshift (9289da8) [$] took 2m34s
❯ echo "$?"
1

nixpkgs_timeshift (9289da8) [$]
❯ NIXPKGS_ALLOW_UNFREE=1 nix run --impure .#vscode -- --help
Invalid array length

nixpkgs_timeshift (9289da8) [$] took 2m6s
❯ echo "$?"
1

And here on nixos-23.11:

~ on  shamrock-dotfiles-try-instantnix [✘!?] took 9m52s
❯ nix run github:NixOS/nixpkgs/nixos-23.11#vscodium -- --help

#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804 (see crbug.com/1201626)
#
#
#
#FailureMessage Object: 0x7fff469d2d80
/nix/store/7v3ycrvrmf5c63s75k2xz4c539i4dbrw-vscodium-1.84.2.23317/bin/.codium-wrapped: line 63: 55930 Trace/breakpoint trap   (core dumped) ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"

~ on  shamrock-dotfiles-try-instantnix [✘!?] took 3m37s
❯ NIXPKGS_ALLOW_UNFREE=1 nix run --impure github:NixOS/nixpkgs/nixos-23.11#vscode -- --help

#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804 (see crbug.com/1201626)
#
#
#
#FailureMessage Object: 0x7fff79ca9580
/nix/store/s8rv3v9ddz1c68kplnl86207dail89xv-vscode-1.85.2/bin/.code-wrapped: line 63: 59499 Trace/breakpoint trap   (core dumped) ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
~ on  shamrock-dotfiles-try-instantnix [✘!?] took 1m39s
❯ echo $?
133

The pure evaluation result should be independent to channel updates, and it should be quite reproducible unless the packages are not self-contained.

ShamrockLee commented 7 months ago

Oh wait, something different happens to nixos-unstable, I'm not quite sure what had happened

~ on  shamrock-dotfiles-try-instantnix [✘!?]
❯ nix run github:NixOS/nixpkgs/nixos-unstable#vscodium -- --help
Invalid array length

~ on  shamrock-dotfiles-try-instantnix [✘!?]
❯ NIXPKGS_ALLOW_UNFREE=1 nix run --impure github:NixOS/nixpkgs/nixos-unstable#vscode -- --help
Visual Studio Code 1.86.2

Usage: code [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')

Options
  -d --diff <file> <file>                    Compare two files with each other.
  -m --merge <path1> <path2> <base> <result> Perform a three-way merge by providing paths for two modified versions of a file, the common origin
                                             of both modified versions and the output file to save merge results.
  -a --add <folder>                          Add folder(s) to the last active window.
  -g --goto <file:line[:character]>          Open a file at the path on the specified line and character position.
  -n --new-window                            Force to open a new window.
  -r --reuse-window                          Force to open a file or folder in an already opened window.
  -w --wait                                  Wait for the files to be closed before returning.
  --locale <locale>                          The locale to use (e.g. en-US or zh-TW).
  --user-data-dir <dir>                      Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of
                                             Code.
  --profile <profileName>                    Opens the provided folder or workspace with the given profile and associates the profile with the
                                             workspace. If the profile does not exist, a new empty one is created.
  -h --help                                  Print usage.

Extensions Management
  --extensions-dir <dir>              Set the root path for extensions.
  --list-extensions                   List the installed extensions.
  --show-versions                     Show versions of installed extensions, when using --list-extensions.
  --category <category>               Filters installed extensions by provided category, when using --list-extensions.
  --install-extension <ext-id | path> Installs or updates an extension. The argument is either an extension id or a path to a VSIX. The identifier
                                      of an extension is '${publisher}.${name}'. Use '--force' argument to update to latest version. To install a
                                      specific version provide '@${version}'. For example: 'vscode.csharp@1.2.3'.
  --pre-release                       Installs the pre-release version of the extension, when using --install-extension
  --uninstall-extension <ext-id>      Uninstalls an extension.
  --update-extensions                 Update the installed extensions.
  --enable-proposed-api <ext-id>      Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.

Troubleshooting
  -v --version                    Print version.
  --verbose                       Print verbose output (implies --wait).
  --log <level>                   Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace',
                                  'off'. You can also configure the log level of an extension by passing extension id and log level in the
                                  following format: '${publisher}.${name}:${logLevel}'. For example: 'vscode.csharp:trace'. Can receive one or
                                  more such entries.
  -s --status                     Print process usage and diagnostics information.
  --prof-startup                  Run CPU profiler during startup.
  --disable-extensions            Disable all installed extensions. This option is not persisted and is effective only when the command opens a
                                  new window.
  --disable-extension <ext-id>    Disable the provided extension. This option is not persisted and is effective only when the command opens a new
                                  window.
  --sync <on | off>               Turn sync on or off.
  --inspect-extensions <port>     Allow debugging and profiling of extensions. Check the developer tools for the connection URI.
  --inspect-brk-extensions <port> Allow debugging and profiling of extensions with the extension host being paused after start. Check the
                                  developer tools for the connection URI.
  --disable-gpu                   Disable GPU hardware acceleration.
  --disable-chromium-sandbox      Use this option only when there is requirement to launch the application as sudo user on Linux or when running
                                  as an elevated user in an applocker environment on Windows.
  --telemetry                     Shows all telemetry events which VS code collects.

Subcommands
  tunnel       Make the current machine accessible from vscode.dev or other machines through a secure tunnel
  serve-web    Run a server that displays the editor UI in browsers.

~ on  shamrock-dotfiles-try-instantnix [✘!?]
❯ nix flake show github:NixOS/nixpkgs/nixos-unstable
github:NixOS/nixpkgs/13aff9b34cc32e59d35c62ac9356e4a41198a538
├───checks
│   └───x86_64-linux
│       ├───nixosSystemAcceptsLib: derivation 'nixos-system-nixos-24.05.20240226.13aff9b'
│       └───tarball: derivation 'nixpkgs-tarball-24.05pre20240226.13aff9b'
├───htmlDocs: unknown
├───legacyPackages
│   ├───aarch64-darwin omitted (use '--legacy' to show)
│   ├───aarch64-linux omitted (use '--legacy' to show)
│   ├───armv5tel-linux omitted (use '--legacy' to show)
│   ├───armv6l-linux omitted (use '--legacy' to show)
│   ├───armv7l-linux omitted (use '--legacy' to show)
│   ├───i686-linux omitted (use '--legacy' to show)
│   ├───mipsel-linux omitted (use '--legacy' to show)
│   ├───powerpc64le-linux omitted (use '--legacy' to show)
│   ├───riscv64-linux omitted (use '--legacy' to show)
│   ├───x86_64-darwin omitted (use '--legacy' to show)
│   └───x86_64-linux omitted (use '--legacy' to show)
├───lib: unknown
└───nixosModules
    ├───notDetected: NixOS module
    └───readOnlyPkgs: NixOS module

~ on  shamrock-dotfiles-try-instantnix [✘!?] took 11s
❯ nix flake metadata github:NixOS/nixpkgs/nixos-unstable
Resolved URL:  github:NixOS/nixpkgs/nixos-unstable
Locked URL:    github:NixOS/nixpkgs/13aff9b34cc32e59d35c62ac9356e4a41198a538
Description:   A collection of packages for the Nix package manager
Path:          /nix/store/1gpgihsi21bni03hy6i5ccw9lfrhnbqi-source
Revision:      13aff9b34cc32e59d35c62ac9356e4a41198a538
Last modified: 2024-02-27 05:58:40

But still, the successful execution of vscode on nixos-unstable (13aff9b34cc32e59d35c62ac9356e4a41198a538) doesn't invalidate the errors shown in other cases.

eclairevoyant commented 7 months ago

Can't repro this on master either.

$ git rev-parse HEAD
728d2d1fd999b9be599793a12bae719709129577

$ nix run .#vscodium -- --help | head
VSCodium 1.86.2

Usage: codium [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | codium -')

Options
  -d --diff <file> <file>                    Compare two files with each
                                             other.
  -m --merge <path1> <path2> <base> <result> Perform a three-way merge by

$ env NIXPKGS_ALLOW_UNFREE=1 nix run .#vscode --impure -- --help | head
Visual Studio Code 1.86.2

Usage: code [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')

Options
  -d --diff <file> <file>                    Compare two files with each
                                             other.
  -m --merge <path1> <path2> <base> <result> Perform a three-way merge by
eclairevoyant commented 7 months ago

Maybe we should try a different approach, what output do you see with strace? What file(s) is trying to access, etc

ShamrockLee commented 7 months ago

Here are the strace output logs generated by running code --help and codium --help from both the master branch and the release-23.11 branch inside Nix shells. Their number of lines ranges from 200 to 400.

strace_nixpkgs_master_vscode_help_20240229231100.log strace_nixpkgs_master_vscodium_help_20240229231400.log strace_nixpkgs_release-23.11_vscode_help_20240229231700.log strace_nixpkgs_release-23.11_vscodium_help_20240229231800.log