Skip to content

Add simple elixir plugin#2462

Merged
Lagoja merged 3 commits intojetify-com:mainfrom
clessg:main
Jan 3, 2025
Merged

Add simple elixir plugin#2462
Lagoja merged 3 commits intojetify-com:mainfrom
clessg:main

Conversation

@clessg
Copy link
Contributor

@clessg clessg commented Dec 20, 2024

Summary

Adds a very basic elixir plugin to simplify installation to a simple devbox add elixir. Also now properly stores Mix/Hex artifacts in .devbox/virtenv.

How was it tested?

  • Tested it against the existing elixir example in the repo. Seems to work fine.
  • Tested on my own projects as well, separately on Mac + Ubuntu.

@Lagoja
Copy link
Collaborator

Lagoja commented Jan 2, 2025

Hey @clessg, this PR looks really helpful!

Just wondering -- why does the plugin install CoreServices on darwin systems? Does this fix an issue you were seeing with Elixir and Devbox?

@clessg
Copy link
Contributor Author

clessg commented Jan 2, 2025

Hey John, thanks for the response! So happy to see Devbox is alive and well, I can't live without it now :)

Anyway, yup! I should have mentioned the Darwin part. On Mac/Darwin, the Elixir package file_system (https://hexdocs.pm/file_system/readme.html) fails to install, seemingly because it requires native libraries to compile. That package is used by Phoenix (Elixir's main web framework) and a few other frameworks for live-reloading in the browser. Here is the error message produced:

(devbox) ➜  mix phx.server

18:18:14.316 [info] Compiling file system watcher for Mac...
==> file_system
In file included from c_src/mac/cli.c:2:
In file included from c_src/mac/cli.h:4:
c_src/mac/common.h:5:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from c_src/mac/compat.c:1:
c_src/mac/compat.h:16:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from c_src/mac/main.c:1:
c_src/mac/common.h:5:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

18:18:14.697 [error] Could not compile file system watcher for Mac, try to run "clang   -framework CoreFoundation -framework CoreServices -Wno-deprecated-declarations c_src/mac/*.c -o priv/mac_listener" manually inside the dependency.

Adding CoreServices seems to resolve the issue. Maybe there's another way but I haven't found it. Considering Elixir almost always goes in tandem with Phoenix (a la Ruby and Rails) or another live-reloading framework, I figured I'd throw in that fix to minimize unexpected errors on Mac.

@Lagoja
Copy link
Collaborator

Lagoja commented Jan 3, 2025

Thanks for the explanation! Going to merge and will test further in the next pre-release

@Lagoja Lagoja merged commit 5fa89f8 into jetify-com:main Jan 3, 2025
28 checks passed
yasuaki640 added a commit to yasuaki640/devbox that referenced this pull request Jan 18, 2026
…plugin

The CoreServices framework reference was added to fix file_system package
compilation on macOS (PR jetify-com#2462), but is no longer needed with the new Darwin
SDK pattern introduced in nixpkgs.

With the updated Darwin stdenv, the Apple SDK (including CoreServices) is
now automatically provided, making the explicit framework reference obsolete.
The old pattern using darwin.apple_sdk_11_0 has been removed from nixpkgs,
causing installation failures on macOS.

This change removes the packages section entirely and bumps the plugin
version to 0.0.2.

Fixes jetify-com#2705
Fixes jetify-com#2557
savil pushed a commit that referenced this pull request Jan 19, 2026
## Summary

Fixes the elixir plugin to work with the new Darwin SDK pattern in
nixpkgs by removing the explicit
`darwin.apple_sdk.frameworks.CoreServices` dependency.

## How was it tested?

Tested on **macOS (darwin-arm64)**:

1. **Built devbox locally**: `devbox run build`
2. **Added elixir package**: `devbox add elixir`
   - ✅ No `darwin.apple_sdk_11_0 has been removed` error
   - ✅ Successfully installed Elixir 1.18.1 with Erlang/OTP 27

<img width="736" height="37" alt="image"
src="https://github.com/user-attachments/assets/5808dfab-b525-4816-a19c-69ba8070dfaa"
/>

3. **Verified elixir functionality**: `elixir --version` successfully
showed version information

<img width="1506" height="272" alt="image"
src="https://github.com/user-attachments/assets/37230f7f-1b2a-42c4-83da-c8db28b70984"
/>

4. **Tested the original issue** - compiling `file_system` package (used
by Phoenix for Live Reload):
   - Created a Mix project with `file_system` dependency
   - ✅ Successfully compiled the native macOS FSEvents watcher
   - Log output: `Compiling file system watcher for Mac... Done.`

<img width="609" height="203" alt="image"
src="https://github.com/user-attachments/assets/b13e60c5-1c38-417a-926c-fa4d358dc5b6"
/>

This confirms that the CoreServices framework is now automatically
available through the new Darwin stdenv, and the explicit
`darwin.apple_sdk.frameworks.CoreServices` package reference is no
longer needed.

## Background

The elixir plugin currently includes
`darwin.apple_sdk.frameworks.CoreServices` in its packages section
(added in
#2462 (comment)
to fix `file_system` package compilation on macOS). However, this
reference uses the old Darwin SDK pattern that has been removed from
nixpkgs.

As documented in
[NixOS/nixpkgs#354146](NixOS/nixpkgs#354146),
nixpkgs has migrated to a new Darwin SDK pattern where:
- The stdenv now provides a default SDK automatically
- Framework dependencies like CoreServices are bundled in the SDK
- Explicit framework references using the old `darwin.apple_sdk_11_0`
pattern cause errors

## Changes

- Removed the `packages` section from `plugins/elixir.json`
- Bumped plugin version from `0.0.1` to `0.0.2`

The `file_system` package will continue to work on macOS because
CoreServices is now automatically available through the new Darwin
stdenv.

Fixes #2705
Fixes #2557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants