Turbo crashes with any command in Official Node Docker image (Alpine) - turbo

Turbo crashes when using any command (e.g. turbo build), even when a valid project and turbo.json exists. This doesn't seem to be a problem on Ubuntu, but only on Alpine (arm64).
I've tried all of the new versions but they have the same issue.
npm install --global turbo
npm install --global turbo#latest
npm install --global turbo#canary
error:
thread 'main' panicked at 'Failed to execute turbo.: Os { code: 2, kind: NotFound, message: "No such file or directory" }', crates/turborepo/src/main.rs:23:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Because I was stuck on this for a few hours, I'll share solution here (which I also shared on Github):
If using a Dockerfile: add RUN apk add --no-cache libc6-compat to it
If using it on an Alpine machine, run apk add --no-cache libc6-compat
More explanation in:
Docker Node image docs
Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.
The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements.
One common issue that may arise is a missing shared library ... . To add the missing shared libraries to your image, adding the libc6-compat package in your Dockerfile is recommended: apk add --no-cache libc6-compat
https://github.com/vercel/turbo/issues/3373#issuecomment-1397080265

Related

Next failed to load SWC binary

When trying to run the command using nextjs npm run dev shows error - failed to load SWC binary see more info here: https://nextjs.org/docs/messages/failed-loading-swc.
I've tried uninstalling node and reinstalling it again with version 16.13 but without success, on the vercel page, but unsuccessful so far. Any tips?
Also, I noticed it's a current issue on NextJS discussion page and it has to do with the new Rust-base compiler which is faster than Babel.
Delete the package-lock.json file and the node_modules directory in your project and then run npm install on your terminal.
This worked as suggeted by nextJS docs but it takes away Rust compiler and all its benefits... Here is what I did for those who eventually get stuck...
Step 1. add this line or edit next.json.js
{
swcMinify: false // it should be false by default
}
Step 2. add a ".babelrc" file to project root dir
Step 3. add this snippet to the new file ".babelrc"
{
"presets": ["next/babel"]
}
Step 4, you need to run this command as steps 1-3 will remove SWC failed to load error but you will notice another error when you run the build command. So run this too
npm install next#canary
hope this helps
If you use Docker, just add RUN npm install -D #swc/cli #swc/core to Dockerfile.
I have the same issue, don't know why, I am using
node v18.4.0
next#12.1.6
to fix this issue
just visit this website
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
install this
I had the same issue on Windows 11. I upgraded NodeJS to 17.0.1. After that, everything works now.
make .babelrc in root directory. And add the following code.
{ "presets": ["next/babel"], "plugins": [["styled-components", { "ssr": true }]] }
This error occurs because next js uses a Rust-based compiler to compile JavaScript which is much faster than babel but this is not compatible with all system architecture, in other to fix this you have to disable this compiler and use the native babel compiler. This is done by creating a .babelrc file in your root directory and adding this code below to the file;
{"presets": ["next/babel"]}
you can check out this link for more details: SWC Failed to Load - NEXTJS DOCS
If you are running using Docker, I had to use node:14-buster-slim as my base image to make it work. I got the idea for my working solution from https://github.com/vercel/next.js/discussions/30468#discussioncomment-1598941.
My multi-staged Dockerfile looks like this:
############### Base Image ###############
FROM node:14-buster-slim AS base
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
############### Build Image ###############
FROM base AS build
ARG app_env=production
ARG app_port=3000
WORKDIR /build
COPY --from=base /app ./
ENV NODE_ENV=${app_env}
ENV PORT=${app_port}
EXPOSE ${app_port}
RUN npm run build
############### Deploy Image ###############
FROM node:14.18.1-alpine AS production
ARG app_env=production
ENV NODE_ENV=${app_env}
WORKDIR /app
COPY --from=build /build/package*.json ./
COPY --from=build /build/.next ./.next
COPY --from=build /build/public ./public
RUN npm install next
EXPOSE 3000
CMD npm run start
If you want to use docker-compose to run your services, the docker-compose.yaml file for running the next dev will look something like this:
version: "3"
services:
web-server:
env_file:
- ./.env
build:
context: .
dockerfile: Dockerfile
target: base
command: npm run dev
container_name: web-server
restart: always
volumes:
- ./:/app
- /app/node_modules
ports:
- "${NODEJS_PORT}:3000"
In your NextJS Project you have this file , named .eslintrc.json, In this file
You have following code
{
"extends": "next/core-web-vitals"
}
Replace it with
{
"extends": ["next/babel","next/core-web-vitals"]
}
The best way to fixed this problem on Windows is install "Microsoft Visual C++ Redistributable"
The error is occurring because Next.js is using Rust-based compiler SWC to compile JavaScript/TypeScript now and for this SWC requires a binary be downloaded that is compatible specific to your system.
To Solve this problem :
Just go to Microsoft Visual C++ Redistributable to download
latest supported Microsoft Visual C++ Redistributable.
Or, you can simply download from here (please check your version first)
Permalink for latest supported x64 version
The X64 Redistributable package contains both ARM64 and X64 binaries. This package makes it easy to install required Visual C++ ARM64 binaries when the X64 Redistributable is installed on an ARM64 device.
Permalink for latest supported x86 version
Permalink for latest supported ARM64 version
Just run 'npm i' or 'yarn' and then restart the server.
Remove node_modules directory and package-lock.json
Run npm i to install the dependencies
If you are on MAC OS, you can directly run below command in terminal
rm -rf node_modules && rm package-lock.json && npm i
In my case issue was with NextJs version 12.2. I have downgraded it to 12.1.6 and my issue is fixed.
I'm a beginner with next.js and I had the same error. After searching I got a solution to add .babelrc. but using that couldn't get the features of SWC.
Today I got a real solution, using this example project command. When we create our new project, then swc will work as well as no error will be there.
command- npx create-next-app 'your_project_name' --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter"
Let me know if you face any further issues.
Just Download Redistributable C++ 2015
If you read the docs it says you need a distributable file which can be downloaded at https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-
Best solution for this problem is
Delete your package-lock.json.
Downgrade your next.js version "12.1.6" from current version.
run npm i --force command.
now run npm run dev command and it will work.
This is Happen because of you have uninstalled npm modules or yarn in your project
Just Run this command / install node packages you will get your back

Build failed with 500, please run 'jupyter lab build' on the server for full output in Jupyter lab

I am trying to add an extension in the jupyter lab. I go to extensions tab and click "install" on the extension. After a few seconds i get a pop up saying Build failed with 500, please run 'jupyter lab build' on the server for full output
could anyone tell me how to resolve it or find the logs related to that error atleast.
Using terminal, try jupyter lab build, which will produce an output on your AppData\Local\Temp folder (if you are on Windows). The log file will give more info on what is causing the failure during the build.
I had the same issue and npm dependencies were the culprit. I have updated conda with conda update -n base -c defaults conda and and yarn with conda install yarn and it solved the issue for me.
Also try looking at this one Jupyter Labs: “RuntimeError: npm dependencies failed to install” When Building.
For me this was fixed by pinning down a lower version of nodejs.
conda install -c conda-forge 'nodejs<16.14' did the trick. My resolution steps:
Install an environment from scratch conda create -c conda-forge -n <your_env_name> 'python>=3.8,<3.11' 'jupyterlab>=3.10'
Then attempt a nodejs install for example conda install -c conda-forge 'nodejs<16.14'
Attempt to build with jupyter lab build in terminal.
It's currently May 2022. Please note versions change a lot and very fast, when you face this same issue :)
On the UI (User Interface) of Jupyter Lab you see
Build failed with 524, please run 'jupyter lab build' on the server for full output
You open a console and run
jupyter lab build
Which ends with
An error occurred.
RuntimeError: JupyterLab failed to build
See the log file for details: /tmp/jupyterlab-debug-2znox977.log
Inside the log you see
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Run again
jupyter lab build --minimize=False
This completes successfully.
Explanation:
dev-build: This option controls whether a dev or a more streamlined production build is used. This option will default to
False (i.e., the production build) for most users. However, if you
have any labextensions installed from local files, this option will
instead default to True. Explicitly setting dev-build to False
will ensure that the production build is used in all circumstances.
minimize: This option controls whether your JS bundle is minified during the Webpack build, which helps to improve JupyterLab's overall
performance. However, the minifier plugin used by Webpack is very
memory intensive, so turning it off may help the build finish
successfully in low-memory environments.
In my case, the VM (Virtual Machine) had 3.75GB RAM and before crashing it was using ~3GB (you can see with htop in another console/terminal [image below]).

How to tell Visual Studio Code compiled from source where to find sqlite module?

I am building the Visual Studio Code from the source checked out from the git repository:
git clone https://github.com/microsoft/vscode
I am building using:
export NODE_OPTIONS=--max_old_space_size=2048
./scripts/npm.sh install --arch=armhf
./scripts/code.sh
I am using node 10.16.3 on a Raspberry PI 4, using Raspbian buster
There were no errors during build.
The installation downloads a precompiled version of electron on the first run.
However each time I try and run code, it starts but with an error:
[storage state.vscdb] open(): Unable to open DB due to Error: Cannot find module '../build/Release/sqlite
If I look in node_modules/vscode-sqlite3/build/Release/
I can see:
sqlite3.a
sqlite.a
It is unclear to me why electron/vscode cannot find this library. I would be greatful for any pointers on how to tell the runtime where to look for the modules.
On inspecting the build scripts and after many painful experiments, I've found and solved the 2 problems leading to this error.
The fact that .a static libraries are left behind hinted that some settings in the binding.gyp, config.gpy and/or makefiles are wrong, as Native Node Modules are normally dynamic libraries with an .node extension. One conditional line in the binding.gyp file under vscode-sqlite3 seems to the the culprit:
...
["target_arch=='arm'", {"type": "static_library"}]
...
Disable that line (by removing it or changing 'arm' to something else) and then run:
node-gyp configure
to regenerate the config.gpy file(s) under the build directory. Then build the module with:
node-gyp build
A sqlite.node will be generated in build/Release.
Unfortunately, the latest electron ABI version rarely matches that of the Node.js version. In my configuration, the electron ABI version is 72 (v6.0.12) but the latest stable Node version is for ABI 64. Therefore we have to do an electron-rebuild to update the sqlite.node to match the electron version.
To do this, you would have to first install electron-rebuild (yarn add electron-rebuild) then run electron-rebuild by giving supplying explicitly the version number of the electron binary that vscode downloaded:
electron-rebuild -v 6.0.12 -m /home/dev/vscode -o vscode-sqlite3
Of course you would have to state the version number of your particular version of electron you are building for.
(Please look up electron-rebuild --help for the meaning of the options. It takes a while to rebuild the binary module...)
The resulting sqlite.node can then be moved into the build/Release/. directory under the vscode project directory. Voila, we have a working latest version VS-Code for Raspbian!

Symlink lost within Docker image

I am defining a Dockerfile where I install sqlite3 in a ubuntu based image, something very similar (I also install grpc and rust as well as all the necessary dependencies) to:
FROM ubuntu
RUN apt-get update && \
apt-get install -y sqlite3 libsqlite3-dev&& \
apt-get clean && \
apt-get autoremove
I use this image to built my Rust project within it. The issue that I am facing is that cargo build fails on my GitLab CI due to a linking issue:
Compiling migrations_macros v1.4.0
error: linking with `cc` failed: exit code: 1
...
= note: /usr/bin/ld: cannot find -lsqlite3
I found out that this is due to this symlink not being present on the Docker image that is running on CI:
libsqlite3.so -> /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
while the file libsqlite3.so.0.8.6 exists. So if I create the symlink during the CI jobs I can have a working workaround. The weird thing is that if I pull the same exact image from my registry on my pc and run the container I can build without any issue and any change because the symlink is actually there.
What could be the cause of the problem and how to solve it?
After quite a bit of thinking the following ideas come to my mind which could help.
Docker history
Docker command has a build in feature to view the history of a built image. You have the option to identify the problematic command in the DockerFile.
docker history <image id or name>
For more visual filtering i do recommend dive tool but others are also available on google.
Correct docker version
Since in this scenario the two docker instances are different the question is trivial. Are they on the same version of docker daemon and docker file system driver?

Atom on Raspbian?

Very nooby question, but I'm trying to install Atom text editor on Raspbian Stretch. Is it possible? I've heard because it runs on Electron, it's quite slow for Raspbian. I keep getting an error saying:
E: Unable to locate package atom
I'm following the official instructions for Debian. How can I fix this?
As of today you can't install the official package provided for Debian for its mismatching the hardware platform. Provided binary is for running on x86 hardware, but RPi doesn't come with an Intel/AMD processor, but ARM. So, you most probably need to build it from source yourself.
Primer
So, if you really want to build this from source, you should be aware of the waste of disk space caused by the IMHO poorly implemented build tool which is downloading tons of deps and copying and transpiling code around so you'll end up with 2GB+ of files with 80% accounting to dependencies, only. Since my RPi works with 8GB smartcard, only, I couldn't ever meet the need for disk space even though I was bleeding out Linux by manually removing docs, manpages, locales, ton's of outdated and mostly unused apps etc. The build also requires a whole build tooling chain, tons of dev packages for libraries, so there is a limit to milk the system ... 8GB disk drive simply isn't enough for this.
Eventually I tried moving all the files to a USB pen drive. But that drive must be formatted using a filesystem capable of symlinking. So you can't use vfat or FAT32. I didn't succeed to get a 16GB stick formatted with either version of extfs. The mkfs always ended up in a deadlock on trying to write its superblocks. Astonishingly, I couldn't even kill the mkfs with -KILL, but unplugging the drive did help in that case.
So, as a conclusion: here is a short list of steps I passed in expectation to get this working, but in the end I didn't finish due to the memory issues above. And frankly, I stopped caring ... I'd rather work with nano/vi in a terminal than using this ridiculous lego-like built software. I guess, atom is today's version of emacs with regards to the latter's acronym. Maybe you succeed with this, but I won't ...
Build from Source
Inspired by https://discuss.atom.io/t/atom-on-the-raspberry-pi/33332
Install toolchain for building native stuff
sudo apt-get install build-essential git libgnome-keyring-dev fakeroot gconf2 gconf-service libgtk2.0-0 libudev1 libgcrypt20 python rpm libsecret-1-dev xorg-dev
This set of tools was sufficient to build core files without error. Since I didn't start with a fresh installation of Raspbian there might have been some tool I have been using before, so maybe in your case there are more tools to be installed here. Look out for error messages in early stage of building and try to see if some library or header file isn't found. This mostly indicates lack of some package with name ending in -dev to be installed, too. Start by searching for the package using apt search <name-of-mentioned-library> and look for a package combining the missing library's name with suffix -dev. Then install it the usual way by invoking sudo apt-get install <package-name>.
Install up-to-date nodejs
Raspbian Stretch comes with support for NodeJS 8.11 which is basically okay. Install it and its package manager npm using this command:
sudo apt-get install node-js npm
Check installed versions with
node -v
npm -v
This should display 8.x.x on behalf of NodeJs. Use n afterwards if you want to step up:
sudo npm i -g n
sudo n lts
This will switch NodeJS to latest LTS release, which is 10.x as of now. Upgrading NodeJS is optional, but feel advised to always use latest version of npm:
sudo npm i -g npm
Check if upgrades succeeded:
node -v
npm -v
Adjust configuration of npm and install some essential dep:
sudo npm config set -g python /usr/bin/python2
sudo npm i -g node-gyp
Build Atom
Get the source. One option is to pull latest code from its repository:
git clone https://github.com/atom/atom.git
This is creating subfolder atom containing all source files. You might want to download sources of a recent release instead. But this tutorial was made with the sources fetched from Github. So make sure there is subfolder called atom containing sources similar to the ones fetched above.
It's time to start the beast:
cd atom
./script/build
This process will take a while. And it is the culprit that never finished on success in my case due to eating up all disk space over and over again.
Whenever the script fails on error, try to analyze the error, find the cause, fix it, then start the script by repeating the last command above again. If you don't remove any file in subfolder atom in between, the build script keeps passing steps of building atom it has passed successfully before.
Install atom
According to the original tutorial linked before the script should finish on success eventually. Then it's time to install with:
./script/grunt install
I guess this is causing atom to be available as a command from CLI. So, try it out. If everything looks fine you are finally ready to remove the waste of files in subfolder atom.
Feel free to report if this was working in your case.
From what I recall Atom runs 64-bit architecture; need the latest raspberry Pi.
run the following
wget https://atom.io/download/deb && dpkg -i deb

Resources