#ruby-on-rails #linux #ubuntu
#ruby-на-рельсах #linux #убунту
Вопрос:
Я справляюсь с этим https://guides.rubyonrails.org/getting_started.html Я уже завершил большую часть первоначальной настройки и застрял на последней части установки rails.
Версия Ruby — это
ruby 2.7.0p0 (2019-12-25 редакция 647ee6f091) [x86_64-linux-gnu]
Когда я запускаю
sudo gem install rails
Я получаю следующий результат
redd@tanya:~$ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.7.0/gems/nio4r-2.5.8/ext/nio4r
/usr/bin/ruby2.7 -I /usr/lib/ruby/2.7.0 -r ./siteconf20211210-14142-ms6vi8.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
--without-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=/usr/bin/$(RUBY_BASE_NAME)2.7
--with-unistd-dir
--without-unistd-dir
--with-unistd-include
--without-unistd-include=${unistd-dir}/include
--with-unistd-lib
--without-unistd-lib=${unistd-dir}/lib
/usr/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.7.0/mkmf.rb:613:in `try_cpp'
from /usr/lib/ruby/2.7.0/mkmf.rb:1124:in `block in have_header'
from /usr/lib/ruby/2.7.0/mkmf.rb:971:in `block in checking_for'
from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'
from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'
from /usr/lib/ruby/2.7.0/mkmf.rb:970:in `checking_for'
from /usr/lib/ruby/2.7.0/mkmf.rb:1123:in `have_header'
from extconf.rb:15:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/nio4r-2.5.8/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.7.0/gems/nio4r-2.5.8 for inspection.
Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/nio4r-2.5.8/gem_make.out
Я уже перепробовал все исправления, упомянутые здесь: https://www.youtube.com/watch?v=ikIOpRnO1x4
Я был бы признателен за любую помощь в решении этой проблемы. Кроме того, если вы знаете процесс поиска решения, пожалуйста, упомяните и об этом. Спасибо вам за уделенное время.
Комментарии:
1. Обычно вы не должны устанавливать драгоценные камни, такие как rails, как sudo. Есть ли у вас такая же проблема без sudo?
2. @SuneNilausen Когда я пытаюсь gem установить rails без sudo. Я получаю «ОШИБКА: при выполнении gem… (Gem::FilePermissionError) У вас нет прав на запись для каталога /var/lib/gems/2.7.0 «.
3. Установите build-essentials и повторите попытку. Кроме того, делитесь деталями ОС, спрашивая о проблемах, связанных с установкой. Для Debian, Mac, M1 mac и т. Д. Все по-другому.
4. @FaizaanKhan Большое вам спасибо. Ваше решение сработало. Моя ОС — Ubuntu версии 20.4 btw. В следующий раз обязательно укажите сведения об ОС.