Developing on Apple silicon with CLion and Parallels Desktop
This is a development environment setup guide that may be helpful for those on Apple silicon. There are likely improvements to be made, but the steps are purposefully overly "hand hold-y" and detailed to be useful to a wider audience.
This guide assumes you are following it from top to bottom.
Environment
The environment used when writing this guide:
- Processor: Apple M1
- operating system: macOS Ventura
- Virtualizer one of:
- Parallels Desktop for Mac 18 Pro Edition
- A Standard edition exists, and may be enough. Parallels offers a trial period.
- UTM emulator/virtualizer
- Free, though its performance is not guaranteed and may take more work for you
- Parallels Desktop for Mac 18 Pro Edition
- Virtual Machine (VM) operating system: Ubuntu 22.04 ARM64 (available in the choice list when creating a VM in Parallels)
- IDE: JetBrains CLion 2022.3
- Visual Studio Code will likely work as well, but the steps for setup are not noted in this guide as of yet.
Parallels VM Setup
- Download and install Parallels Desktop for Mac
- Create a new VM (File -> New -> Download Ubuntu Linux -> Continue)
- After the VM is installed and starts up, shut down the VM before logging in
- Open Parallels Control Center (Window -> Control Center)
- Click the gear icon next to the VM to open the VM's Configuration menu to make the configuration to your preferences.
The following are mine:
- Options -> Sharing -> Disable all but "Share Mac volumes with Linux"
- Options -> Sharing -> Disable "Share Linux applications with Mac"
- Hardware -> Processors -> 6 (Standard edition allows up to 4, which should be fine)
- Hardware -> Memory -> 16384 MB (16GB; Standard edition allows up to 8GB which should be fine)
- Graphics -> More Space (scaling will be done in the VM)
- Start the VM again and enter a password to set it. You may have some windows demanding your attention:
- Parallels asking for the password to use
sudo
and install Parallels Tools. Enter your password. Once it is done installing, it will start a countdown to restart the VM...click postpone, or be quick. - Livepatch setup, which seems impossible to just close.
- Continue -> "No, don't send system info" (unless you want to) -> Next -> Next -> Done
- Parallels asking for the password to use
- Restart and log in again
- (Optional) Right click the desktop -> Display Settings -> Adjust to your preferences
- (Optional, still in Settings) Keyboard -> View and Customize Shortcuts -> Search for "lock" -> Disable it so you don't accidentally lock your VM every time you want to clear the terminal.
- (Optional, still in Settings) Power -> Screen Blank -> Never
- (Optional) Right click the desktop -> Open in Terminal -> Click the Hamburger menu button -> Adjust to your
preferences. The following are mine:
- General -> Theme variant -> Dark
- Unnamed -> Colors -> Text and Background Color -> Set Built-in schemes = Solarized dark
- Unnamed -> Colors -> Palette -> Set Built-in schemes = Solarized
- Create an empty directory where the Aurae files will be synced. This guide assumes you will create it on the desktop
at
Desktop/aurae
. - (Optional) Now might be a good time to snapshot the VM (feel free to do it at any other step)
- Open Parallels Control Center (Window -> Control Center)
- Right click your VM -> Manage Snapshots -> New -> Set a name ("Init") -> Ok
UTM Setup
Do not do this if you're using Parallels. You only need one VM.
- Download and install UTM from releases https://github.com/utmapp/UTM/releases
- Download the Ubuntu ISO and create a new VM: https://docs.getutm.app/guides/ubuntu/
- I never got clipboard sharing working, just decided to SSH in and rely on my host system.
ip a | grep addr
to get the address and then regularssh username@ip
(and whatever extras you prefer to set) - Set up shared drive: follow https://docs.getutm.app/guest-support/linux/#virtfs then
- add this line to
/etc/fstab
:share [mount point] 9p trans=virtio,version=9p2000.L,rw,_netdev,nofail 0 0
- Mount share and fix permissions (does not modify the host files, just inside-VM settings. Preserved between restarts.):
sudo mount /share sudo chown 1000:1000 /share
- add this line to
Everything else should proceed the same.
CLion Setup
- Download and install CLion.
- This is on your mac, not in the VM. We will use CLion's remote development features to connect to the VM.
- Open the Aurae project in CLion
- Install plugins (CLion -> Setting -> Plugins)
- Rust
- Protocol Buffers
- Deno
- Restart the IDE to finish installing the plugins
- Activate the experimental Rust plugin features
- Open CLion's "search everywhere" window (can be opened via magnifying glass in upper right corner)
- Search for and select "Experimental Features"
- Activate all options that start with "org.rust"
- Setup remote development (CLion -> Settings -> Build, Execution, Deployment -> Development)
- Click the + icon -> SFTP -> Enter a name ("AuraeVM")
- Connection -> SSH configuration -> click the "..."
- Set Host to the IP address of the VM (Parallels -> Devices -> Network -> an IP address should be listed)
- Set Username to "parallels"
- Set Password to your VM's password -> select "Save Password" -> de-select "Parse config file ~/.ssh/config"
- Clicking Test Connection should show a success message
- Select Ok, to close the menu (we will be back in Settings)
- Connection -> Root path -> click Autodetect (my root path becomes "/home/parallels")
- Connection -> Select "Use Rsync for download/upload/sync"
- Mappings -> Local path -> should be set to the path to the Aurae project on your mac
- Mappings -> Deployment path ->
Desktop/aurae
(the empty directory created in the VM) - Excluded Paths -> + -> Local path -> path to the "target" directory in the Aurae project directory on your mac
- Click apply to save the settings so far
- Configure development options (CLion -> Settings -> Build, Execution, Deployment -> Development -> Options)
- The following options are selected:
- Overwrite up-to-date files
- Preserve file timestamps
- Delete target items when source ones do not exist
- Create empty directories
- Prompt when overwriting or deleting local items
- Upload changed files automatically to the default server -> Always
- Delete remote files when local are deleted
- Preserve original file permissions -> No
- Warn when uploading over newer file -> No
- The following options are selected:
- Configure the default deployment server
- Open CLion's "search everywhere" window (can be opened via magnifying glass in upper right corner)
- Search "Show Default Deployment Server" -> set to "On"
- Click the now visible "Remote Development" on the bottom bar -> Remote Development -> AuraeVM
- Upload the project to the VM
- Open the Project window -> right click the root of the project -> Deployment -> Upload to AuraeVM
- Changed files should automatically be uploaded, based on our settings, but CLion seems to use save events to trigger the upload. Manually triggering the upload like this should only be required when the project files change without CLion realizing, such as when switching git branches
- Syncing only occurs from host to vm, but some files are generated on build. To sync from vm to host, open the Project window -> right click the root of the project -> Deployment -> Sync with Deployed to AuraeVM. ( Generated files should not be checked in.)
- Open the Project window -> right click the root of the project -> Deployment -> Upload to AuraeVM
Back to the VM (setting up Aurae)
Some of these steps are documented at Building from Source. These steps are likely going to get out of sync with the actual dependencies in the project. The GHA build image manifest file is also a good source to see the project's dependencies.
- Check the
Desktop/aurae
directory, it should no longer be empty - Install dependencies. In the terminal run...
sudo apt-get update; sudo apt-get install -y protobuf-compiler; sudo apt-get install -y musl-tools; sudo apt-get install -y build-essential; sudo apt-get install -y llvm-15-dev; # bpf-linker dependency sudo apt-get install -y libclang-15-dev; # bpf-linker dependency
- Install rust:
- Open the browser in the VM -> https://rustup.rs -> copy the command (this is an official Rust project, so we trust the command)
- Run the command -> Select option 1 ("Proceed with installation (default)") when prompted
- Either follow the onscreen instructions to update PATH or close and reopen the terminal
- Run
rustup target add aarch64-unknown-linux-musl
- Install buf
- Buf Installation Docs
- Homebrew is not an option
- Binary works
- Open a terminal (the directory should not be in your
Desktop/aurae
directory; desktop is easiest) - Run
touch buf.sh
- Run
vi buf.sh
- Copy + paste the code block on the buf website
- Hit ESC then ":wq" to save and exit
- Run
sudo -E sh buf.sh
- Open a terminal (the directory should not be in your
- Build and install Aurae (terminal must be in the
Desktop/aurae
directory)make pki config; make build;
- auraed needs to be run using sudo (
sudo -E auraed
), but Ubuntu will not let you for security reasons- Option A: use the full path:
sudo -E [full path to auraed installed by cargo]
- Option B: remove the security
- Run
sudo -E visudo
- Comment out the line "Defaults secure_path=..." by prefixing it with "#" (disables security)
- Save & exit via Ctrl+x -> Y -> ENTER
- Run
- Option C: ease the security
- add the path of the directory where cargo installed auraed to the same line indicated in option B.
- Option A: use the full path: