6 ms·
Anyone have recommendations for devs looking to run a dev environment on a Mac without installing a bunch of dev dependencies on the local machine? My plan rig
by cj 3y ago
Anyone have recommendations for devs looking to run a dev environment on a Mac without installing a bunch of dev dependencies on the local machine?
My plan right now is to buy a 2nd mac and use VS Code remote development over ssh.
- smw 3y agoDoes nix or devbox [1] do what you want? Technically installing on the local machine, but not in any way that effects you unless you ask for it? [1] https://www.jetpack.io/devbox https://www.jetpack.io/devbox
- yonatan8070 3y agoWhy not just have everything you need on your local machine? (I'm not a Mac user)
- frizlab 3y agoI am a Mac user and I’m curious to know too
- cj 3y agoExecuting a bunch of npm modules locally, having a Mongo and Redis database running 24/7. I don’t have a great answer. One thing I’ve noticed on Mac is that, using Activity Monitor, before installing all the dev dependencies for local dev nearly all processes seem to run under the local user’s user space, but after installing a bunch of stuff (with sudo) a ton of processes default to running as “system” I haven’t had time to research whether this actually has a meaningful impact on security, but TLDR I trust Mac’s out of the box security, but I instantly stop trusting it the moment I start installing a bunch of stuff via Homebrew and NPM.
- comprev 3y agonvm for Node + use containers for database services?
- cj 3y agonvm doesn’t stop npm modules from installing locally. many npm modules have pre/post install scripts that execute binaries and such that I’d rather not execute locally Docker for Redis/Mongo is reasonable, but npm dependencies creeping into the system is something you can’t really easily undo other than a full wipe and reinstall of the OS. Especially when certain modules require sudo to install
- comprev 3y agoDocker volumes might help with the module management too through executing npm i side a container. YMMV as performance can sometimes be an issue.
- chrisweekly 3y agotangent: fnm https://github.com/Schniz/fnm https://github.com/Schniz/fnm is faster than nvm and much cleaner in its shell integration.
- eyelidlessness 3y agoYou generally shouldn’t ever use sudo with either Homebrew or NPM. Homebrew is specifically designed to be used without elevated privileges. This has the downside that packages are owned by the user which first ran the install (which might lead to those packages running with elevated privileges after a sudo install as well? I don’t know, and I’m not eager to find out). NPM packages are typically either project local (and these definitely shouldn’t be installed with sudo), or “global” (which should be global in the sense of being installed on the user’s PATH, and thus shouldn’t require sudo for any normal setup either). You’re right to be cautious about the security implications of this.
- pxc 3y ago> This has the downside that packages are owned by the user which first ran the install This is a bit of a security problem if Homebrew's .../bin is on your sudoers secure_path, because now your normal user can overwrite something that might be invoked via a simple `sudo whatever`, which doesn't specify the full path to whatever > which might lead to those packages running with elevated privileges after a sudo install as well? I don’t know, and I’m not eager to find out No, definitely not by any normal mechanism. Maybe there are some exception, like packages that set up LaunchAgents or LaunchDaemons, or which run the install scripts of .pkg installers which ask for elevated privileges. But those can set up programs that run with elevated privileges anyway.
- comprev 3y agoBrew will prompt for elevated privileged when necessary, or at least formulae should conform to that design
- chrisweekly 3y agoStrong rec to avoid use of sudo for brew or (p)npm, not sure why you'd want to do that.
- newaccount74 3y agosudo or not makes very little difference, unless you actually use multiple user accounts with different privileges on your Mac.
- chrisweekly 3y agoit makes a big difference if you don't want to practice poor security hygiene and form a bad habit of constantly entering your password for no reason.
- deleted 3y ago[deleted]
- newaccount74 3y agoThe nice thing about the Mac is that you can run a lot of unix tools natively. But of course, anything that runs on your Mac is a potential security hole. Obviously all 3rd party apps that you use can compromise security. But it can also be your own code: If eg. your rails app has a security vulnerability, which is common during development, and you run it with your local user, as is common during dev, then that vulnerability can potentially compromise all your data. So if you want to be safe, run all your dev stuff in VMs or on a separate device, or in a container or something. Of course, that is cumbersome, and whether it is necessary or not depends on what kind of threats you expect...
- makeitdouble 3y agoDepends on why you're a mac in the first place. For me it was iOS adjacent dev, and that meant upgrading the building stack every year, uncluding straight OS upgrades. And thus screwing my other dependencies every year. After the third or fourth time, I switched to a VM that will stay stable basically whatever happens to the system.
- jfoutz 3y agoSo, Mac doesn't come with a package manager. There are things you can do with port and brew, to alleviate some pain. Me personally, I fool around with a lot of languages, and sometimes I don't quite keep every project up to date with the latest version. For work, the situation is even more challenging, because I don't have the authority to go tell teams to upgrade or not upgrade, but sometimes I need to build their projects. None of this is really Mac specific. I used to use virtual box for this, which worked pretty well. I could set up a baseline environment and snapshot new boxes with new language revs. Docker can kind of cover this, but I tend to over do it, breaking things out into the one you build with, and the one you run with, and it's fine, but it's a lot to keep in my head. So, I'm kinda flakey about that. Now, I'm slowly building up some proficiency with nix. I think this is what I really want, to swap out the whole chain of system dependencies, and build docker containers or vms out of that if I need them. Perhaps I'm a poor sysadmin. _everything_ locally installed makes things real weird after a while (years).
- cj 3y ago> Perhaps I'm a poor sysadmin. _everything_ locally installed makes things real weird after a while (years). Same experience here (years). Because it’s something that creeps up over time, the problems aren’t obvious overnight.
- fsflover 3y agoThis is one of the good reasons to use Qubes OS.
- moojd 3y agoMy path was vm -> containers -> nix. With nix flakes and the direnv extension in vscode you can get a clean per-project dev environment with zero docker overhead and without dev tools cluttering up your global environment and causing issues.
- jbverschoor 3y agoUse orbstack, install things in their own container, Mount local volumes
- coffeeri 3y agoDepends on what you are trying to solve. If you don't like the fragmentations of dependencies on your system, this won't go away on a second machine. Also, I'd point you to hosted VS Code environments such as GitHubs code spaces or Gitpod. You may use something that encapsulates your dev dependencies. Some use containers like docker, others use Nix (can be run on MacOS ). As Nix has quite a steep learning curve, there are abstractions such as devenv or devbox, which I haven't used.
- lostlogin 3y agoWould UTM be an option? https://mac.getutm.app/ https://mac.getutm.app/
- chaxor 3y agoUtm is just qemu, and qemu is actually open source. Utm hides an enormous amount of what they do (just saying not open source again in a different way), and that's definitely not what you want in a base system. So it would likely be much better to simply install qemu instead.
- noodlesUK 3y agoUTM is open source (Apache2). You can also add any argument supported by the bundled version of QEMU using the GUI. https://github.com/utmapp/UTM/blob/main/LICENSE https://github.com/utmapp/UTM/blob/main/LICENSE
- c-hendricks 3y agoUTM uses qemu or Apple's own virtualization framework, which runs macOS.
- pxc 3y agoDoes UTM not use Hypervisor.framework through QEMU? QEMU has built-in support for HVF: https://wiki.qemu.org/Features/HVF https://wiki.qemu.org/Features/HVF
- Aaron2222 3y agoThere's the Hypervisor framework, which is the low-level framework that replaces the need for a kernel extension for type 2 hypervisors, and then there's the more recent Virtualisation framework which is a more high-level framework for running VMs. QEMU's HVF uses the Hypervisor framework, and UTM also supports running VMs with the Virtualization framework (which is what Vimy and Viable also use). Note that the Virtualization framework also has support on Apple Silicon for running macOS guests as well as Linux guests.
- sharts 3y agoSetup a remote server anywhere. Install ThinLinc. Done.
- salzig 3y ago> ThinLinc is a software that enables organizations to implement a Linux server-based computing (SBC) infrastructure. - https://www.cendio.com/thinlinc/what-is-thinlinc/ https://www.cendio.com/thinlinc/what-is-thinlinc/ Back to terminal server again.
- fredoliveira 3y agoI've tried a few things: - Docker, but the docker on mac experience has never been great (even if Colima or Orbstack makes that much better) - A VM running on my mac where I install whatever I need. Tried debian, silverblue, and used the opportunity to properly learn Nix and use NixOS - My current setup, especially for hairy projects with dependencies I dislike: an intel NUC running in my local network that I set up with NixOS which runs everything I need. Because I install Tailscale everywhere, I can use it even when working from outside my home.
- navels 3y agoCurrent setup on my M1 for dev is to use docker with containers for mysql, localstack, rabbitmq, redis, and ruby (debian bullseye), all arm64 images, and then VS Code with the remote container extension. Was pretty rough going when the M1 first came out but is now flawless and lightning fast. Onboarding new devs takes an hour instead of a day.
- ngai_aku 3y agoVS Code remote so you don’t have to pay the cost of volume mount? Is performance that much better? I’m not a VS Code user, do you need things like the lsp server baked into your image to get intellisense to work?
- vorpalhex 3y agoRaspberry pi or other compact linux machine with code-server running in docker. Gets you a web UI that works from anything (ie iPad) and you can do docker-in-docker for other containers. SBCs have less horsepower but you can always run them from a USB battery bank, letting you dev on the go.
- syntaxing 3y agoAre you building apps for Mac/iOS? If not, I have a 12 core Ryzen with a 3090 that was the same price as a higher ram Mac mini ($1K). I recommend that over another Mac if you’re ok running *nix.
- rafram 3y agoThe OP is clearly asking about setting up a Mac dev environment, so suggesting that they buy a non-Mac machine is not helpful.
- jjnoakes 3y agoIt isn't so clear to me. As I read it, OP might be asking about a dev environment on Mac, not necessarily for Mac-only development.
- heavyset_go 3y agoThere are multiple ways to interpret the OP's statement.
- musicale 3y agoNot sure if PP was using a desktop or a laptop. MacBook Air isn't a gaming rig but it's a nice, quiet, power-efficient laptop.
- bonestamp2 3y agoI would use a VM. You could also use Vagrant in that VM to make it easy to setup that environment again in another VM (or machine) later: https://developer.hashicorp.com/vagrant/intro https://developer.hashicorp.com/vagrant/intro
- afruitpie 3y agoMicrosoft's Dev Containers [0] is pretty slick, especially when used with GitHub Codespaces [1] if you want remote development. [0] https://containers.dev https://containers.dev [1] https://github.com/features/codespaces https://github.com/features/codespaces
- upbeat_general 3y ago+1 for VSCode Remote. I've been coding for the past 2 years almost exclusively through VSCode remote on Linux servers with few complaints. Get a seperate SFTP/network file client as the built-in VSCode one is slow and unstable but otherwise everything works great. If you're considering using any Jetbrains IDE over a network connection however, I'd encourage you to think again.