headmelted / codebuilds

Community builds of Visual Studio Code for Chromebooks and Raspberry Pi
https://code.headmelted.com
MIT License
1.03k stars 56 forks source link

Missing module error on UserLand (Android) #97

Open danielhodder opened 4 years ago

danielhodder commented 4 years ago

On Android, using the UserLand linux container, when launching the code-oss binary a relative load path error is encoutered.

$ code-oss
internal/modules/cjs/loader.js:630
    throw err;
    ^

Error: Cannot find module './bootstrap'
Require stack:
- /usr/share/code-oss/resources/app/out/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:627:15)
    at Function.Module._load (internal/modules/cjs/loader.js:531:27)
    at Module.require (internal/modules/cjs/loader.js:685:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/usr/share/code-oss/resources/app/out/cli.js:9:19)
    at Module._compile (internal/modules/cjs/loader.js:786:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
    at Module.load (internal/modules/cjs/loader.js:645:32)
    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:850:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/share/code-oss/resources/app/out/cli.js' ]
}

This is very similar to an issue which is present with npm in node 10, and later, in userland. CypherpunkArmory/UserLAnd#938

I reproduced this on the ubuntu flavor of userland with the xfce desktop environment.

sethleedy commented 4 years ago

FYI, I have also come across this error on my mobile device. Using Userland on LXDL Desktop, on a Pixel 3a device.

seth@localhost:~$ code-oss internal/modules/cjs/loader.js:720 throw err; ^

Error: Cannot find module './bootstrap' Require stack:

danielhodder commented 4 years ago

Yup that's the same issue. Unfortunately, there's been no movement on either of the issues in UserLAnd. For now you can compile a customer version of UserLAnd with the proot fix and that seems to work.

sethleedy commented 4 years ago

Will test when I can. Lots to do this week yet.

Lavaerius commented 4 years ago

Pardon my ignorance, how do I merge the proot changes into userland for use with a distro?

Incidentally, I'm currently stuck just getting proot to compile.

danielhodder commented 4 years ago

This doesn't seem to be well documented and I can't find my exact notes anymore. You use https://github.com/CypherpunkArmory/UserLAnd-Assets-Support but I think I modified some of the scripts slightly. You need to not pull proot from github but instead copy the version from this branch in.

That will will build a proot binary, which you can then rename to proot.so and put it into https://github.com/CypherpunkArmory/UserLAnd. It needs to be renamed because Android doesn't allow shipping binary executables, but they do allow shared libraries for some reason.

Once you've done that I side-loaded the APK from Android Studio using developer mode on my phone/tablet. Hope that helps some.

danielhodder commented 4 years ago

Oh for clarity I cloned the repo and started it like this:

$ docker run --rm -it --volume $PWD/UserLAnd-Assets-Support:/build termux/package-builder
dabdoue commented 4 years ago

Sorry, but I'm a beginner, so is there anyway you could provide a more step-by-step guide to fixing the error?

Lavaerius commented 4 years ago

I'm going to leave out some finer details, but this is what I did:

android studio up to date clone https://github.com/CypherpunkArmory/UserLAnd and import workspace into android studio get virtualbox installed, and get a debian vm running on debian vm install git clone https://github.com/CypherpunkArmory/UserLAnd-Assets-Support inside that directory run: sed -e 's/CypherpunkArmory/danielhodder/' -i scripts/buildArch.sh on vm install docker following this process: https://docs.docker.com/install/linux/docker-ce/debian/ run docker command from home directory docker run --rm -it --volume $PWD/UserLAnd-Assets-Support:/build termux/package-builder (I hard coded PWD to the directory the asset-support folder was cloned into) once container is up and running, and you're interactive navigate to /build/scripts run ./buildArch.sh arm64 (or whatever your target arch is) after it's done, delete output directory navigate to build/proot directory and run git checkout remotes/origin/bugfix/UserLAnd_97_fix_seccomp_handling_for_unknown_system_calls navigate back to script directory re run your buildArch.sh arm64 figure out how to get the output directory back to your main machine

navigate to your Userland base directory, and then to: app/src/main/jniLibs/the arch you chose rename the files in your output directory to match what's in the jnilibs folder proot -> lib_proot.so...etc. kick your build job kick your apk build get the apk to your device install it run it test it

Lavaerius commented 4 years ago

oh, almost forgot, in userland when attempting to launch code-oss from vnc session, it still fails run this:

sed -i 's/BIG-REQUESTS/_IG-REQUESTS/' /usr/lib/your_arch_here-linux-gnu/libxcb.so.1

danielhodder commented 4 years ago

Thanks for providing the instructions. I hope that helps.