Can't source .bashrc when setup.bash is in a symbolic folder [closed]

asked 2021-01-05 20:39:41 -0500

lyh458 gravatar image

updated 2021-01-06 07:40:05 -0500

Hi,

I have a dual system (Ubuntu 18.04 and Windows 10) in a Dell notebook, I want all my codes to store in a folder of windows disk, so I create a symbolic link (soft link) in ubuntu with the command ln -s /mnt/windisk/codes ~/codes, that is the folder ~/codes in ubuntu point to the folder /mnt/windisk/codes in windows, and I can use the files in ~/codes folder with cd command or directly with Files Manager.

However, source ~/.bashrc not work even though I have added the source command to ~/.bashrc. For example:

  • I create a workspace catkin_ws in folder ~/codes, then a package name test in src folder,
  • catkin_make successfully.
  • Add command source ~/codes/catkin_ws/devel/setup.bash in ~/.bashrc, the source it with command source ~/.bashrc
  • Run roscd tes, and double press the keyboard keys Tab, it can't automatically complete roscd test, which means that source ~/codes/catkin_ws/devel/setup.bash not work well.

  • But if I directly run source ~/codes/catkin_ws/devel/setup.bash or source /mnt/windisk/codes/catkin_ws/devel/setup.bash, or add source /mnt/windisk/codes/catkin_ws/devel/setup.bash in ~/.bashrc, everything work well.

Do you have any idea about this problem? Thanks!

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by lyh458
close date 2021-01-05 23:15:38.204428

Comments

If closing a question as a duplicate, please always link to the whatever this is a duplicate of.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-06 03:35:27 -0500 )edit
1

And an observation:

I want all my codes to store in a folder of windows disk, so I create a symbolic link (soft link) in ubuntu with the command ln -s /mnt/windisk/codes ~/codes, that is the folder ~/codes in ubuntu point to the folder /mnt/windisk/codes in windows, and I can use the files in ~/codes folder with cd command or directly with Files Manager.

don't do this.

Windows file systems and Linux file systems use different ways to encode permissions, leading to all sorts of problems when trying to do what you describe.

I'd strongly suggest you reconsider what you are attempting to do.

If you want to keep things in-sync between Windows and Linux, use a proper version control system, such as Git.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-06 03:37:20 -0500 )edit

Thanks, @gvdhoorn. I have solved the problem. This is actually a workspace overlaying problem. Because I have several workspaces, some environment variables of them would be overlaid when run source ~/.bashrc, and which results in the packages missing. In my case, the environment variables are stored in <catkin_ws>/devel/_setup_util.py line 271 CMAKE_PREFIX_PATH.

So I create a new workspace (such as catkin_overlay_ws) specifically for storing all environment variables of other workspaces and only add source ~/Codes/catkin_overlay_ws/devel/setup.bash to ~/.bashrc. And now, everything is ok.

BTW, Git is a good in-sync tool, but not suitable for large files. I want all my codes and files created or modified in ubuntu can be saved in the same folder/disk as windows, and so far I have not met any permission problem.

lyh458 gravatar image lyh458  ( 2021-01-06 07:38:44 -0500 )edit
2

If you're happy, I'm happy. I've seen far too many workspaces get corrupted by doing what you are doing.

Besides permission problems, NTFS is also very slow compared to Linux FS, so performance may be poor.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-06 07:50:21 -0500 )edit