bitwarden / desktop

The desktop vault (Windows, macOS, & Linux).
https://bitwarden.com
GNU General Public License v3.0
3.54k stars 399 forks source link

npm run build fails: /bin/sh: line 1: rustup: command not found #1492

Closed JensTimmerman closed 2 years ago

JensTimmerman commented 2 years ago

Steps To Reproduce

Follow the build instructions in the readme:

 sudo dnf install nodejs npm rust glib2-devel libsecret-devel
Last metadata expiration check: 1:38:01 ago on Tue 19 Apr 2022 04:31:21 PM CEST.
Package nodejs-1:16.14.0-2.fc35.x86_64 is already installed.
Package npm-1:8.3.1-1.16.14.0.2.fc35.x86_64 is already installed.
Package rust-1.60.0-1.fc35.x86_64 is already installed.
Package glib2-devel-2.70.5-1.fc35.x86_64 is already installed.
Package libsecret-devel-0.20.4-3.fc35.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

git clone https://github.com/bitwarden/desktop.git
cd desktop_native
npm ci
npm run build

Expected Result

native_desktop is built

Actual Result

This fails with:


> @bitwarden/desktop_native@0.1.0 build
> napi build dist --platform --release --js true

/bin/sh: line 1: rustup: command not found
Internal Error: Command failed: rustup show active-toolchain
/bin/sh: line 1: rustup: command not found

/bin/sh: line 1: rustup: command not found

    at checkExecSyncError (node:child_process:828:11)
    at Object.execSync (node:child_process:902:15)
    at BuildCommand.<anonymous> (/home/jens/workplace/desktop/desktop_native/node_modules/@napi-rs/cli/scripts/index.js:14525:55)
    at Generator.next (<anonymous>)
    at fulfilled (/home/jens/workplace/desktop/desktop_native/node_modules/@napi-rs/cli/scripts/index.js:3423:58)

Screenshots or Videos

No response

Additional Context

I'm running this on Fedora 35, rustup doesn't seem to be in the fedora repositories.

Operating System

Linux

Operating System Version

Fedora 35

Installation method

Other

Build Version

master: 3862a19571b10899ebb8c97c0b4bd3bc175f0070

JensTimmerman commented 2 years ago

Seems like one needs to pass --target somewhere to prevent napi-rs from trying to call rustup https://github.com/napi-rs/napi-rs/issues/869

JensTimmerman commented 2 years ago

Applying this patch made this work for me, since I am on an x86_64 linux gnu system, I don't have enought rust/npm experience to try and find a cross platform solution here :s

diff --git a/desktop_native/package.json b/desktop_native/package.json
index 7fe4c970..4d0dc7e7 100644
--- a/desktop_native/package.json
+++ b/desktop_native/package.json
@@ -4,7 +4,7 @@
   "description": "",
   "main": "index.node",
   "scripts": {
-    "build": "napi build dist --platform --release --js true",
+    "build": "napi build dist --platform --release --js true --target x86_64-unknown-linux-gnu",
     "build:debug": "napi build dist --platform --js true",
     "build:cross-platform": "node build.js",
     "test": "cargo test"
Hinton commented 2 years ago

Hmm, we should probably update the documentation that rustup is expected to be installed if it fails without it.

Hinton commented 2 years ago

Hi @JensTimmerman,

Apologies for the constant changes in build instructions. We discovered an issue with compiling rust for windows 32bit and decided to hold off on the migration to rust for now.