Network devices not found after Ubuntu upgrade from 20.04 LTS to 22.04 LTS

I had recently upgraded my laptop from Ubuntu 20.04 from 22.04. Once restarted after the upgrade, my laptop just wouldn’t connect to any network (LAN/Wifi/USB tethering)

I ran this command to see the network devices:

sudo lshw -c network

Which gave a very similar result as this:

*-network UNCLAIMED       
   description: Ethernet controller
   product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
   vendor: Realtek Semiconductor Co., Ltd.
   physical id: 0
   bus info: pci@0000:03:00.0
   version: 03
   width: 64 bits
   clock: 33MHz
   capabilities: pm msi pciexpress msix vpd bus_master cap_list
   configuration: latency=0
   resources: ioport:d800(size=256) memory:f8fff000-f8ffffff memory:f8ff8000-f8ffbfff memory:f9ee0000-f9efffff


 *-network UNCLAIMED
   description: Network controller
   product: RTL8812AE 802.11ac PCIe Wireless Network Adapter
   vendor: Realtek Semiconductor Co., Ltd.
   physical id: 0
   bus info: pci@0000:02:00.0
   version: 01
   width: 64 bits
   clock: 33MHz
   capabilities: pm msi pciexpress bus_master cap_list
   configuration: latency=0
   resources: ioport:c800(size=256) memory:f9dfc000-f9dfffff

Solution

After some research these were the steps which I followed to get the network devices and the network connectivity back

In terminal, run

uname -r
6.5.0-25-generic

Note the output, for me it was “6.5.0-25-generic”

From another computer, download linux-modules-extra-6.5.0-25-generic.deb from here.

Please note that depending on the kernel version you are running (as indicated by the uname output,) your exact .deb file will be different.

Copy the downloaded .deb file into the network-broken laptop using a pen-drive.

Now in the network-broken laptop, cd to the location of the .deb file.

Run

sudo dpkg -i linux-modules-extra-6.5.0-25-generic_6.5.0-25.25~22.04.1_amd64.deb

Restart the laptop.

The network devices and network connectivity was restored.

Fix ChromaDB startup error: Your system has an unsupported version of sqlite3.

Problem:

After installing chromadb, when we try to start it using the command

 chroma run --host localhost --port 8000 --path /home/user/chromadata

Its give this error:

Traceback (most recent call last):
  File "/home/dheeyantra/.local/bin/chroma", line 5, in <module>
    from chromadb.cli.cli import app
  File "/home/dheeyantra/.local/lib/python3.8/site-packages/chromadb/__init__.py", line 79, in <module>
    raise RuntimeError(
RuntimeError: Your system has an unsupported version of sqlite3. Chroma                     requires sqlite3 >= 3.35.0.
Please visit                     https://docs.trychroma.com/troubleshooting#sqlite to learn how                     to upgrade.

Fix:

pip install pysqlite3-binary
vi ~/.local/lib/python3.8/site-packages/chromadb/__init__.py

#add these lines to the TOP OF THE FILE and save it.
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

Start the chromadb. Should work now.

A QR Code Scanner Component for Cordova in ReactJS that works on Android.

Yes, a component that does the job well. Code below, customise for your use case.

Note: It does not use the “cordova-plugin-qrscanner” which is broken at the time of writing.

import React, { Component } from "react";
import jsQR from "jsqr";
import $ from "jquery";

class QrCodeScanner extends Component {
  constructor(props) {
    super(props);
    this.videoRef = React.createRef();
    this.state = {
      qrcode: "",
      videoError: false
    }
  }

  componentDidMount() {
    this.checkCameraPermissions();
  }

  componentWillUnmount() {
    this.stopScanner();
  }

  checkCameraPermissions = async () => {
    var thisController = this;

    cordova.plugins.permissions.requestPermission(
      cordova.plugins.permissions.CAMERA,
      function (status) {
        if (status.hasPermission) {
          console.log("Camera permission granted");
          thisController.startScanner();
        } else {
          console.log("Camera permission denied");
          thisController.state.videoError = true;
          thisController.setState(thisController.state);
        }
      },
      function () {
        console.log("Error requesting camera permission");
        thisController.state.videoError = true;
        thisController.setState(thisController.state);
      }
    );
  };

  startScanner = () => {
    navigator.mediaDevices.getUserMedia({ video: { facingMode: "environment" } })
      .then((stream) => {
        this.videoRef.current.srcObject = stream;
        this.videoRef.current.play();
        this.videoRef.current.addEventListener("loadedmetadata", this.scanFrame);
      })
      .catch((error) => {
        console.error("Error starting scanner: ", error);
        this.state.videoError = true;
      });
  };

  stopScanner = () => {
    const stream = this.videoRef.current.srcObject;
    if (stream) {
      const tracks = stream.getTracks();
      tracks.forEach((track) => {
        track.stop();
      });
    }
    document.getElementById("qrScannerPreview").pause();
  };

  scanFrame = () => {
    var thisController = this;
    const canvas = document.createElement("canvas");
    const context = canvas.getContext("2d");
    const video = this.videoRef.current;

    canvas.width = video.videoWidth;
    canvas.height = video.videoHeight;
    context.drawImage(video, 0, 0, canvas.width, canvas.height);
    const imageData = context.getImageData(0, 0, canvas.width, canvas.height);

    const code = jsQR(imageData.data, imageData.width, imageData.height);
    if (code) {
      console.log("QR code detected: ", code.data);
      //Do something with the extracted code.

        return;
      }

    }

    requestAnimationFrame(this.scanFrame);
  };


  render() {

    return (
      <div style={{ height: "90vh", marginTop: "7vh" }} >

        <div id="view-qrscanner" >
          <div>
            <div className="container-qr">
              <div style={{ paddingTop: "1vh" }} >
                <div align="center">
                  <h3 style={{ fontWeight: 'bold', fontSize: "1.28rem", color: 'white' }}>Scan your onboarding QR code</h3>
                  <label style={{ padding: "10vw", fontSize: "0.92rem", color: 'white' }}>Postion the QR Code a few inches away</label>
                </div>
                <div id="camera" className="pre_capture_frame" style={{ width: '95vw' }} />
                {!this.state.videoError && <video style={{ width: "85vw", height: "85vw", margin: '4.5vw', borderRadius: '12px' }}
                  ref={this.videoRef} id="qrScannerPreview" />}
                {this.state.videoError && <div>Could not start the video source.
                  Please ensure that you have granted camera permissions and that 
                  the camera is not being used by another app.</div>}
                <br />
                <div id="tick" align="center" style={{ display: 'none', color: '#94bde9',
                                                     fontSize: '108px', width: '95vw' }}>
                  &#10004;
                </div>
              </div>

            </div>
          </div>
        </div>

      </div>
    );
  }
}

export default QrCodeScanner;

Fix: Cordova App on Android shows blank screen with ERR_CONNECTION_REFUSED

Problem: The Cordova App when run on Android give a Connection refused error on https://localhost/* URLs.

Fix: Follow these steps:

  • Edit package.json
  • Set homepage from “./” to “https://10.0.2.2/”
  • Save, build and run the App.

Probable Reason: Localhost seems to get routed to the host while the emulator runs the App within a virtual container (assumption).
10.0.2.2 is a special IP mapped to the “localhost” of the emulated environment.

Convert ReactJS App to Android App on Ubuntu

Install Cordova

npm install cordova -g

Create a Cordova project

cordova create ReactBasedPhoneApp

Open package.json of the existing ReactJS App.
Copy the sections – scripts, dependencies, browserList from the above package.json and paste it into the ReactBasedPhoneApp/package.json

Build the existing ReactJS App

npm run build

After the build completes successfully, copy the contents inside the build folder of the existing reactJS app to ReactBasedPhoneApp/www folder

Set Android Home

export ANDROID_SDK_ROOT=/home/{username}/Android/Sdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Add Android plugin

cordova platform add android

#in case you use phone camera in the application
cordova plugin add cordova-plugin-camera

Build the APK

cordova build android

#if you want to debug the app in a running simulator or USB connected android phone
cordova run android

Upgrade NodeJS on Ubuntu

Here are the steps you can follow to upgrade NodeJS on an Ubuntu system.

sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/bin/node*
sudo rm -rf /usr/local/include/node*

sudo apt-get purge nodejs npm
sudo apt autoremove

Download the latest installable archive for your OS from https://nodejs.org/en/download/

tar -xf your-archiveFile
sudo mv extracted-archiveFolder-name/bin/* /usr/local/bin/
sudo mv extracted-archiveFolder-name/lib/node_modules/ /usr/local/lib/
node -v
#should display the latest version of node

Easy Engine – change domain on WordPress website.

I had recently lost my domain codemarvels.com; the warning emails from my domain provider was reaching a currently unused inbox, and thus had to spawn up the same website on codemarvels.in (the one that you are currently on).

The only command that worked for me on my EasyEngine deployment (for my ssl enabled website) was:

#upgrade to ee4 with this command
wget -qO ee https://rt.cx/ee4 && sudo bash ee

#clone existing website to new one.
ee site clone codemarvels.com codemarvels.in --ssl=le

If your new domain is mapped to this server, it should be ready for serving.

Clear Maven Cache: Solution to transitive dependencies not updating on clean install

Follow these steps when maven clean install just doesn’t update the transitive dependencies in nested projects.

rm -rf .m2/repository/path-to-your-library
cd your-project-folder
find . -maxdepth 2 -name "pom.xml"  -exec mvn clean -f '{}' \;
mvn clean install -DskipTests=true
#confirm if the versions are as you wanted
mvn dependency:tree | grep -B 75 the-bugging-library

If the above method doesn’t work, you might have missed to add the required version in the dependency management.

Lets assume BL is the library which has been bugging you with these version issues 😉

cd your-mvn-parent-project
vi pom.xml
#add
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>BL-group</groupId>
                <artifactId>BL-artefact</artifactId>
                <version>required-version-of-the-BL</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

Let me know if these steps helped.