Skip to content

Symbolic link issues

ATmobica edited this page Feb 1, 2021 · 1 revision

Windows10 & WSL & Linux symbolic link creating

Description

If you run a CHIP project with Visual Studio Code VS development you may have run into an issue with creating symlinks. The problem is a bit complex because you checkout the CHIP project on Windows OS but run Docker image under Linux system. As a result, the CHIP project's symbolic links may be created incorrectly. You can see that symbolic links are checked out as small plain files that contain the link text.

Solution

The simplest solution for this issue could be to convert these plain files to Linux symbolic link. You can use bash script for that:

#!/usr/bin/env bash

dir=$1
if [ ! -d "${dir}" ]; then
echo "Wrong input directory"
exit 1
fi

FILE_LIST=$(git ls-files -s $dir | awk '/120000/{print }')
root=$PWD

for file in $FILE_LIST; do
    read -r link_path <$file
    ln -sf "$root/${file%/*}/$link_path" "$root/$file"
done

Create a conversion script in the root CHIP project directory. Then run by passing in the argument the directory in which the conversion should be performed.

Example: bash ScriptName.sh examples/shell/nrfconnect/

Result

All plain files with the link text from the indicated directory should be replaced with symbolic links.

Create a symbolic link in GIT

Description

Create a symbolic link in a project which is correctly interpreted by GIT.

Solution

The reference path of the source file should be relative to the repository, not absolute to the machine. More: Symbolic links in Git

Symlink inside mbed project

Description

When you adding the symbolic link inside the mbed project directory which points to the directory inside which the project itself is located calling a mbed-tools's configure causes its endless action.

Solution

Probably a "med-tool configure" command searches the project catalog for needed components. If we add a symbolic link to the parent directory we will create a kind of infinite reference loops for this mechanism. Consequently, calling a "configure" command never ends. Proposed solution: Do not create a symbolic link inside the mbed project directory if we want to use the mbed-tools to build the project.