jdx/mise

`mise use -g ruby` compile error from fresh installation

Closed this issue · 2 comments

Describe the bug
I recently discovered mise and seems like an awesome tool. I started migrating my workflow over. I'm installing mise via Homebrew and tried installing Ruby which then gives me a compile error.

To Reproduce

  1. Fresh install of Mise
  2. Install Ruby using mise use -g ruby

Expected behavior
Latest version of Ruby is installed

mise doctor output

❯ mise doctor
version: 2024.11.16 macos-arm64 (2024-11-18)
activated: yes
shims_on_path: no

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Mon, 18 Nov 2024 12:17:25 +0000
  Rust Version: rustc 1.82.0 (f6e511eec 2024-10-15) (Homebrew)
  Profile: release

shell:
  /bin/zsh
  zsh 5.9 (arm64-apple-darwin24.0)

dirs:
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/Library/Caches/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files:
  ~/.config/mise/config.toml

backends:
  aqua
  asdf
  cargo
  core
  go
  npm
  pipx
  spm
  ubi
  vfox
  unknown

plugins:

toolset:
  ubi:jdx/usage@1.3.2
  core:node@23.2.0
  core:bun@1.1.34

env_vars:
  MISE_SHELL=zsh

settings:
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cache_prune_age = "30d"
  ci = false
  color = true
  debug = false
  disable_backends = []
  disable_default_registry = false
  disable_hints = []
  disable_tools = []
  experimental = false
  fetch_remote_versions_cache = "1h"
  fetch_remote_versions_timeout = "10s"
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  http_timeout = "30s"
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  libgit2 = true
  lockfile = false
  log_level = "info"
  not_found_auto_install = true
  paranoid = false
  pin = false
  plugin_autoupdate_last_check_duration = "7d"
  quiet = false
  raw = false
  task_timings = false
  trace = false
  trusted_config_paths = []
  unix_default_file_shell_args = ["sh"]
  unix_default_inline_shell_args = [
      "sh",
      "-c",
  ]
  use_file_shell_for_executable_tasks = false
  use_versions_host = true
  verbose = false
  windows_default_file_shell_args = [
      "cmd",
      "/c",
  ]
  windows_default_inline_shell_args = [
      "cmd",
      "/c",
  ]
  windows_executable_extensions = [
      "exe",
      "bat",
      "cmd",
      "com",
      "ps1",
      "vbs",
  ]
  yes = false

  [cargo]
  binstall = true

  [node]

  [npm]
  bun = false

  [pipx]
  uvx = false

  [python]
  default_packages_file = "~/.default-python-packages"
  pyenv_repo = "https://github.com/pyenv/pyenv.git"
  venv_auto_create = false
  venv_stdlib = false

  [ruby]
  default_packages_file = "~/.default-gems"
  ruby_build_repo = "https://github.com/rbenv/ruby-build.git"
  ruby_install = false
  ruby_install_repo = "https://github.com/postmodern/ruby-install.git"

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false
No warnings found
No problems found

Additional context

Running: mise use -g ruby

❯ mise use -g ruby
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.1M  100 21.1M    0     0  6504k      0  0:00:03  0:00:03 --:--:-- 6504k
*** Following extensions are not compiled:
psych:
        Could not be configured. It will not be installed.
        Check /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.R9Dn9N/ruby-3.3.6/ext/psych/mkmf.log for more details.
BUILD FAILED (macOS 15.1 on arm64 using ruby-build 20241105)
You can inspect the build directory at /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.R9Dn9N
See the full build log at /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.log
mise ERROR ~/Library/Caches/mise/ruby/ruby-build/bin/ruby-build failed
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.3.6.tar.gz...
-> curl -q -fL -o ruby-3.3.6.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.6.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.1M  100 21.1M    0     0  6504k      0  0:00:03  0:00:03 --:--:-- 6504k
==> Installing ruby-3.3.6...
-> ./configure "--prefix=$HOME/.local/share/mise/installs/ruby/3.3.6" --with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared --with-ext=openssl,psych,+
-> make -j 8
*** Following extensions are not compiled:
psych:
        Could not be configured. It will not be installed.
        Check /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.R9Dn9N/ruby-3.3.6/ext/psych/mkmf.log for more details.

BUILD FAILED (macOS 15.1 on arm64 using ruby-build 20241105)

You can inspect the build directory at /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.R9Dn9N
See the full build log at /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.log
mise ERROR failed to install core:ruby@3.3.6
mise ERROR ~/Library/Caches/mise/ruby/ruby-build/bin/ruby-build exited with non-zero status: exit code 1
mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information

log

❯ cat /var/folders/cv/kg5k4vqs3p9dhn9x6n07lngc0000gn/T/ruby-build.20241119133659.61686.R9Dn9N/ruby-3.3.6/ext/psych/mkmf.log
pkg_config: checking for pkg-config for yaml-0.1... -------------------- not found

package configuration for yaml-0.1 is not found
--------------------

find_header: checking for yaml.h... -------------------- no

DYLD_LIBRARY_PATH=.:../.. "clang -o conftest -I../../.ext/include/arm64-darwin24 -I../.././include -I../.././ext/psych -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -fno-common -pipe conftest.c  -L. -L../.. -L. -fstack-protector-strong  -arch arm64   -lruby.3.3-static -framework CoreFoundation -ldl -lobjc -lpthread   -lpthread  "
ld: warning: ignoring duplicate libraries: '-lpthread'
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_LIBRARY_PATH=.:../.. "clang -I../../.ext/include/arm64-darwin24 -I../.././include -I../.././ext/psych -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -fno-common -pipe -arch arm64  -c conftest.c"
conftest.c:3:10: fatal error: 'yaml.h' file not found
    3 | #include <yaml.h>
      |          ^~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <yaml.h>
/* end */

--------------------

Okay I found the issue. I didn't realize I needed to install extra dependencies.

  1. Add system dependencies for ruby-build
    brew install openssl@3 readline libyaml gmp autoconf

  2. Install ruby-build
    brew install ruby-build

  3. mise use -g ruby work flawlessly.

I often get caught by this when I am using mise to install a Ruby environment on a fresh Debian system.

Unfortunately, there doesn't seem to be an apt target in Debian that provides the Ruby build dependencies. So I have to install them on the Debian system myself:

$ sudo apt install g++ make libssl-dev libffi-dev zlib1g-dev libyaml-dev

Putting this here in case it's helpful for others.