Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Rails não instala

gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.

current directory: /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/nio4r-2.2.0/ext/nio4r /Users/leandro/.rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20180306-1409-1n5ahe6.rb extconf.rb checking for unistd.h... extconf.rb failed Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/Users/leandro/.rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME) /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:457:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:588:intry_cpp' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:1095:in block in have_header' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:945:inblock in checking_for' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:351:in block (2 levels) in postpone' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:321:inopen' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:351:in block in postpone' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:321:inopen' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:347:in postpone' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:944:inchecking_for' from /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/mkmf.rb:1094:in have_header' from extconf.rb:14:in'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0/nio4r-2.2.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/nio4r-2.2.0 for inspection. Results logged to /Users/leandro/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0/nio4r-2.2.0/gem_make.out

3 respostas

mkmf.log

"gcc -o conftest -I/Users/leandro/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/x86_64-darwin17 -I/Users/leandro/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/ruby/backward -I/Users/leandro/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/leandro/.rvm/rubies/ruby-2.4.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -lruby.2.4.1 -lpthread -ldl -lobjc " xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun checked program was: / begin / 1: #include "ruby.h" 2: 3: int main(int argc, char *argv) 4: { 5: return 0; 6: } / end */

No meu tava instalando a versao 5.1.5 e dando erro. Resolvi usar a mesma versao do curso de rails 4 e deu certo.

Fiz os seguintes comandos para desinstalar a versao nova e colocar a 4.2.1: sudo gem uninstall railties sudo gem install rails -v 4.2.1

solução!

Estava gerando erro de escrita no arquivo /usr/bin.

Na instalação adicionei -n /usr/local/bin e funcionou adequadamente.