ohmybash / oh-my-bash

A delightful community-driven framework for managing your bash configuration, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
https://ohmybash.github.io
MIT License
5.54k stars 626 forks source link

bash: /dev/null: cannot overwrite existing file #479

Closed RayCxggg closed 9 months ago

RayCxggg commented 9 months ago

Hi, I am working on Ubuntu 20.04 with WSL2.

After I install oh-my-bash, it works well for a while. Then when I start a new terminal, it prints 6264f7f6d31d67fb604804fda747a29

It seems that some lines in the .bashrc triggered the problem. The normal functions of bash seem fine so far.

This is my .bash_profile:

if [[ -f ~/.bashrc ]]; then
  source ~/.bashrc
fi

I have only changed the OSH_THEME field and added a few export PATH= lines at the end of .bashrc. Those lines worked fine in my old .bashrc file. Please help me figure out what is wrong. Thanks!

RayCxggg commented 9 months ago

Some add up here. After I typed rm bash, I tried tab to complete the line for rm bash_profile and remove the wrong bash_profile file. However, it printed out the same error again. image

akinomyoga commented 9 months ago

Can you paste the result of the following command?

$ ls -l /dev/null* | cat -v
RayCxggg commented 9 months ago

Here is the output:

root@LAPTOP-LTLGK41V:~# ls -l /dev/null* | cat -v
-bash: /dev/null: cannot overwrite existing file
-bash: /dev/null: cannot overwrite existing file
-rw-r--r-- 1 root root   0 Sep 26 12:35 /dev/null
-rw-r--r-- 1 root root 136 Sep 25 15:09 /dev/null.old
akinomyoga commented 9 months ago

The file /dev/null in your seems to be replaced by a regular file. The file /dev/null should be a character device and the result of ls -l /dev/null should look the following (this is the result in my Ubuntu 20.04/WSL2):

$ ls -l /dev/null*
crw-r--r-- 1 root root 1, 3 2023-09-26 19:33:14 /dev/null

Could you try solutions in the answers in the following Q&A?

RayCxggg commented 9 months ago

Thanks a lot. It perfectly solved the problem. BTW, I am just curious that how /dev/null was changed into a regular file?

akinomyoga commented 9 months ago

Great!

BTW, I am just curious that how /dev/null was changed into a regular file?

Hmm, I don't have an idea. Since we haven't seen other reports to Oh-My-Bash (OMB), I guess it is not caused by OMB. In the past, Bash 4.2 had a bug where /dev/null was removed from the file system when HISTFILE=/dev/null was specified. It might be caused by a similar bug in a certain program.

j17018 commented 7 months ago

The issue is that maybe you tried to copy or to move a file to /dev/null. /dev/null is not a folder, it is a special file. And when a file is moved to /dev/null, it breaks its properties.