Error installing json 1.8.3 with ruby 2.4

Problem

You are trying to install the gems for your rails application in a new computer, or by using ruby 2.4 and you get the following error:

An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

Solution

Remove your old Gemfile.lock file and run bundle again. A newer version of json (ie 1.8.6) should be installed.

FATAL -> Failed to fork – Digital Ocean – Debian – Docker

Problem

When you are trying to install a package inside a debian Docker container you get the following error message:

FATAL -> Failed to fork.

Solution

This is an indication of ‘out of memory’ so add a swap partition if it does not exist, on the host with the following:

fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap sw 0 0" >> /etc/fstab

(Thanks Valent)

Docker – Debian – Kernel panick – Automatic restart

Problem

You have a remote server (Debian) running some Docker containers and you want to make sure that they all restart in the event of a kernel panick.

solution

  • Add an automatic restart after a kernel panick by running:
    sysctl kernel.panic=20
  • Emulate a kernel panick by running the following (SysRq more info here :
    echo c > /proc/sysrq-trigger
  • Check that the containers have restarted again with docker ps (NOTE: the containers should have been enabled to autorestart)

failed to execute ‘/lib/udev/socket:@/org/freedesktop/hal/udev_event’ ‘socket:@/org/freedesktop/hal/udev_event’

Problem

Looking at your /var/log/syslog you see entries every few seconds like the following:

Mar  1 15:44:52 L530 systemd-udevd[11464]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory
Mar  1 15:44:52 L530 systemd-udevd[11451]: Process 'socket:@/org/freedesktop/hal/udev_event' failed with exit code 2.
Mar  1 15:44:54 L530 systemd-udevd[11479]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory
Mar  1 15:44:54 L530 systemd-udevd[11466]: Process 'socket:@/org/freedesktop/hal/udev_event' failed with exit code 2.

Solution

Seems that hal is not used in newer Ubuntu versions, so you can remove it:

sudo apt-get purge hal

Taken from the answer here

Remove line from bash history

Problem

You want to remove a certain line from your server’s bash history, if for example you pasted a password in the wrong place.

Solution

Use the two steps:

1. history -d line_number to remove from memory
2. history -w to write in-memory history to the history file ~/.bash_history

as described here

When the shell is not bash (sh) you can remove them from ~/.ash_history and then source the file.

Changing default editor for crontab from nano to vim

Problem

You would like to change the default editor for crontab from nano to vim.

Solution

Add the following to the ~/.selected_editor:

SELECTED_EDITOR="/usr/bin/vim"

or run the select-editor and choose vim-basic (4)

server# select-editor 

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/mcedit
  4. /usr/bin/vim.basic
  5. /usr/bin/vim.tiny

Choose 1-5 [2]: 4

Creating routable OpenStreet maps for Garmin

Problem

You would like to use OpenStreet maps in your Garmin GPS, and be able to use navigation.

Solution

  1. Download the program mkgmap from here
  2. Download the map for the country you want from here
  3. Unzip the downloaded files to a folder ie (map_for_a_country)
  4. Unzip the mkgmap and run the following to create a map that you can upload to your Garmin’s SD /Garmin/ directory
  5.  ./mkgmap.jar --gmapsupp --index --route --description="Country_Name" $( ls /map_for_a_country/*.img )
  6. Rename gmapsupp.img to country_name.img and upload to your Garmin

NOTE: You might need to run java –jar mkgmap.jar …