You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cloud] emulate user's local directory structure in VM (#440)
## Summary
**Problem**
A scenario we want to protect against is two distinct projects sharing
the same directory name. For example, consider projects located at
`~/customer1/my_project` and `~/customer2/my_project`. Prior to this PR,
we would attempt to sync both projects to the same folder in the VM:
`~/code/my_project`.
**Approach**
This PR attempts to solve this conflict by seeking to emulate the user's
directory structure in the VM. So, for the aforementioned example
projects, they will sync to `~/customer1/my_project` and
`~/customer2/my_project` in the VM as well. This has the additional
benefit that if a user has relative paths between two projects they are
actively developing (for example, a golang library and golang
application that uses that library), then these relative paths will
continue working in the cloud-shell, in accordance with our desires to
make the cloud-shell experience akin to local shells.
**Edge case: projects outside homedir**
An edge case is for projects that are located locally outside the user's
homedir. For security reasons, in the VM, we do not want to give the
user root access, or access to folders outside their homedir. We choose
to sync to a special folder called: `~/outside-homedir-code/<absolute
path>`. For example, a project located locally at
`/my_company/my_project` will sync to
`~/outside-homedir-code/my_company/my_project`. There are two downsides
to this which are tolerable IMO:
1. If a user _also has_ a local folder called `~/devbox-cloud` and they
want to sync those projects then there will be a conflict.
2. Relative paths between a project in homedir and outside the homedir
will not work. The user can inspect the paths in the cloud-shells via
`pwd` and update the relative paths to match that.
## How was it tested?
for `testdata/go/go-1.19`: could sync to VM via `devbox cloud shell`,
and inspect directory in VM with `pwd`.
for edge case: projects outside homedir:
1. copied `examples/testdata/rust/rust-stable` to
`/usr/local/testy-nonhome-dir/rust-stable`
2. fixed permissions: `sudo chown savil:staff
/usr/local/testy-nonhome-dir/rust-stable`
3. `devbox cloud shell` to VM
4. `pwd` in VM gave:
`/home/savil/outside-homedir-code/usr/local/testy-nonhome-dir/rust-stable`
5. `devbox add gcc` and then `cargo run` ran successfully.
0 commit comments