codebuilds icon indicating copy to clipboard operation
codebuilds copied to clipboard

Missing module error on UserLand (Android)

Open danielhodder opened this issue 5 years ago • 10 comments

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.

danielhodder avatar Jan 02 '20 00:01 danielhodder

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:

  • /usr/share/code-oss/resources/app/out/cli.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:717:15) at Module._load (internal/modules/cjs/loader.js:622:27) at Module._load (electron/js2c/asar.js:717:26) at Function.Module._load (electron/js2c/asar.js:717:26) at Module.require (internal/modules/cjs/loader.js:775:19) at require (internal/modules/cjs/helpers.js:68:18) at Object. (/usr/share/code-oss/resources/app/out/cli.js:9:19) at Module._compile (internal/modules/cjs/loader.js:880:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10) at Module.load (internal/modules/cjs/loader.js:735:32) { code: 'MODULE_NOT_FOUND', requireStack: [ '/usr/share/code-oss/resources/app/out/cli.js' ] }

sethleedy avatar Feb 04 '20 19:02 sethleedy

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.

danielhodder avatar Feb 04 '20 19:02 danielhodder

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

sethleedy avatar Feb 10 '20 13:02 sethleedy

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.

Lavaerius avatar Feb 20 '20 15:02 Lavaerius

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 avatar Feb 22 '20 19:02 danielhodder

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

danielhodder avatar Feb 22 '20 20:02 danielhodder

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

dabdoue avatar Feb 24 '20 22:02 dabdoue

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 avatar Feb 27 '20 18:02 Lavaerius

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

Lavaerius avatar Feb 27 '20 18:02 Lavaerius

Thanks for providing the instructions. I hope that helps.

danielhodder avatar Feb 28 '20 07:02 danielhodder