'Rust installation fails on Linux with error "OS 21"

When I tried to install Rust on my Linux machine this error appeared:
error: could not amend shell profile: '/home/$Username/.profile': could not write rcfile file: '/home/$Username/.profile': Is a directory (os error 21)



Solution 1:[1]

Many unix-like systems use the ~/.profile file as a point to place startup code for a user session. There are also other files with a similar function. You should not use that file for any other purpose (like for example it beeing a directory).

Your installation script apparently wants to add some content to that file. This is not unusual, because ~/.profile can be used to set up the search path for programs.

You should rename (or delete) the ~/.profile directory.

I had to delete my .profile folder.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jakob Stark