Avoid referencing a folder name within code inside that folder

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.

Last Updated: 2022-05-26

X asked me to rename the Project S project to have a hyphen in it, so I did it. Part of this included changing the folder name. Immediately afterwards I was getting inexplicable errors.

When I tried curling the web service server based on the code in this folder, I got "no input file". And when I ssh-ed in to the virtual machine residing within that folder, I saw there were no files there at all!

Ultimately this was because of some settings in my Homestead.yaml file (used by my virtual machine, Vagrant)

ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize:
  # ...
  # HERE: should have the newer `project-s` reference instead
  # of `projects` (no hyphen)
  - /Users/jack/.../projects-backend to: /home/vagrant/code

The effect of the out-of-date folder reference was that the virtual machine was referencing a now non-existent folder.

Lesson

Avoid ever putting an explicit reference to the current folder name within your codebase (i.e. "nothing inside a folder should reference the folder name itself") This is because, if you do this, then you can no longer move the code without having to update the code itself. It would have been better to use a relative reference ./

Secondly: Be aware that changing the name of a folder can break long-running (or "restartable") processes/functionality connected to them.