Skip to content

fix(desktop): evaluate MAKE_OPTS so macOS Ruby build gets a valid -jN#24

Open
rafaconrado wants to merge 1 commit into
promovaweb:mainfrom
rafaconrado:fix/macos-ruby-make-opts-quoting
Open

fix(desktop): evaluate MAKE_OPTS so macOS Ruby build gets a valid -jN#24
rafaconrado wants to merge 1 commit into
promovaweb:mainfrom
rafaconrado:fix/macos-ruby-make-opts-quoting

Conversation

@rafaconrado

Copy link
Copy Markdown

Problema

No macOS, o passo [4/14] Ruby Ecosystem (Rails) falha ao compilar o Ruby 3.3.0:

-> make "-j$(nproc" 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)

BUILD FAILED (macOS 26.5.1 on arm64 using ruby-build 20260616)
rbenv: version `3.3.0' not installed
Installing Rails...
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

Causa raiz

A linha do macOS monta MAKE_OPTS com bash -c entre aspas duplas, contendo um valor entre aspas simples com \$(...):

user_do bash -c "export ... export MAKE_OPTS='-j\$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)'; rbenv install 3.3.0"

A substituição de comando nunca é avaliadaMAKE_OPTS fica com a string literal -j$(nproc ...). O ruby-build então executa um make "-j$(nproc" ... inválido, o build falha e o Ruby 3.3.0 não é instalado.

Como consequência, o gem install bundler rails seguinte cai no Ruby do sistema (/Library/Ruby/Gems/2.6.0) e falha com Gem::FilePermissionError.

O caminho Linux (logo abaixo no mesmo step_4) já faz o correto, usando aspas simples no bash -c externo e aspas duplas no valor.

Correção

Alinhar o macOS ao padrão do Linux: aspas simples no bash -c externo + aspas duplas nos valores, para que $(...) seja avaliado pelo shell interno. O valor continua dinâmico (-j = nº de núcleos), apenas passa a ser de fato avaliado.

Teste

Verificado no macOS (Apple Silicon, macOS 26.5.1, ruby-build 20260616):

  • Antes: MAKE_OPTS=[-j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)]BUILD FAILED.
  • Depois: $(...) avaliado corretamente (-j4/-j8/-j10/… conforme a máquina, com fallback -j2); o build roda -> make -jN e instala o Ruby 3.3.0 com sucesso (rbenv versions lista 3.3.0), eliminando o erro de permissão no gem install.

On macOS, step 4 built MAKE_OPTS with a double-quoted `bash -c` wrapping a
single-quoted, backslash-escaped \$(...). The command substitution was never
evaluated, so MAKE_OPTS was the literal string "-j$(nproc ...)". ruby-build
then ran a broken `make "-j$(nproc" 2>/dev/null || sysctl ...`, which fails:

    BUILD FAILED (macOS 26.5.1 on arm64 using ruby-build ...)
    rbenv: version `3.3.0' not installed

With Ruby 3.3.0 missing, the subsequent `gem install bundler rails` fell back
to system Ruby and failed with:

    Gem::FilePermissionError: You don't have write permissions for the
    /Library/Ruby/Gems/2.6.0 directory

Switch to single-quoted outer `bash -c` + double-quoted values so $(...) is
evaluated by the inner shell (mirrors the Linux path). Verified on macOS
(Apple Silicon, macOS 26.5.1): build now runs `make -j10` and installs
Ruby 3.3.0 successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant