'Moving .pyenv folder to another partition, symlinking

This question is related to programming environment setup for python.

I have run out of space on my home folder on Ubuntu. Python shims are stored in their default location ~/.pyenv and taking up a lot of space. To create space, I want to move the whole of .pyenv folder to another partition.

In my understanding, this should be as simple as cut-pasting the `.pyenv' folder to its desired location and creating a soft link at its original location, pointing to this new location. Something like:

ln -s ~/drive2/.pyenv ~/.pyenv

( Where the other disc is mounted at ~/drive2/ )

However, the solutions I see online are much more 'involved'. Here's one example

Am I missing something? Only possible issue I can think of is having too many levels of symlink .



Solution 1:[1]

To answer my own question , this worked well, exactly as expected. The pyenv root directory (/home/usename/.pyenv ) contained a lot of symlinks but all the relative links pointed to sub-folders inside the .pyenv directory itself. Given this, moving the whole folder to another drive did not cause any problems. Here's the process I followed-

  1. Copy (but not cut) the .pyenv folder recursively to desired location, say ~/drive2/.pyenv
  2. Rename the original .pyenv folder to something else and keep it for the time being, in case something goes wrong
  3. Create a soft link to replace the original .pyenv folder and point it to your new location. For example: ln -s ~/drive2/.pyenv ~/.pyenv
  4. Test the system by running some python code that uses virtual environments
  5. If all is satisfactory, delete the renamed folder in step 2 to reclaim the space

I am quite sure the same system will work on Windows with the mkLink command with the \D switch, but someone will have to confirm this.

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 R.S.