netcreateorg / netcreate-2018

Please report bugs, problems, ideas in the project Issues page: https://github.com/netcreateorg/netcreate-2018/issues
Other
11 stars 2 forks source link

DRAFT build compatibility: Add VSC setting to force X86 mode for Apple Silicon #272

Closed daveseah closed 1 year ago

daveseah commented 1 year ago

THIS PULL REQUEST SHOULD NOT BE MERGED WITHOUT TESTING ON MULTIPLE PLATFORMS BY MULTIPLE DEVS

The 2018 build of NetCreate uses an older version of node (set in .nvmrc as v10.22.0). This version does not officially support Apple Silicon (e.g. M1, M2 processors), but we don't want to update it yet because there are many packages that also need updating.

Why is this important?

Many of the packages in NPM have native code elements that have dependencies to a processor and operating system platform, and they often also tied to the nodejs major version. Many the packages used for NetCreate predate Apple Silicon and may not compile correctly, causing unusual errors.

TESTING

This requires an Apple Silicon Mac (M1, M2, etc)

  1. Pull the test branch
  2. Make sure the the integrated terminal isn't already open by clicking the TRASH CAN icon to kill it
  3. Reopen the integrated terminal
  4. Type arch. If it says i386 then it's working

Next, make sure NetCreate is using the correct NodeJS architecture. Since the processor type has changed, it's likely that the codebase may need to be repulled.

  1. cd build
  2. Type nvm version to see what version of node is running. It should be v10.22.0. If it isn't the case then type nvm use.
  3. Type npm ci to reload all the library dependencies set in package-lock.json and see if there are errors.
  4. If no errors, try running netcreate in the usual way and make sure it works.

TECHNICAL INFORMATION

This patch adds the following settings to netcreate-2018.code-workspace

"terminal.integrated.profiles.osx": {
  "x86 zsh": {
    "path": "/usr/bin/arch",
    "args": ["-arch", "x86_64", "zsh"]
  }
},
"terminal.integrated.defaultProfile.osx": "x86 zsh"

The effect of these settings is to define a profile for osx machines "x86 zsh" which will execute the arch command that tells Rosetta (apple's Intel processor emulator) to switch to X86_64 mode when opening the integrated terminal inside of Visual Studio Code. The second setting tells VSC to use this new profile for every new one.

This does not affect other terminal windows, but you can do the same thing by issuing the arch command BEFORE you run npm use && npm ci when starting it up for the first time in a terminal window:

# see current architecture
arch # says arm64
# run a new shell as an emulated intel processor
arch -arch x86_64 /bin/zsh
arch # now says i386
daveseah commented 1 year ago

Github will not let me reassign the base branch (defaulted to master, not dev) so closing