Error installing jekyll: ERROR: Failed to build gem native extension - ruby

I use github+jekyll to build blog, i try to install jekyll to local(windows 10), while it failed when i rungem install jekyll and the stack trace is
C:\Developments\FrontEnd\rubygems-2.7.7>gem install jekyll
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
C:/Developments/FrontEnd/Ruby25-x64/bin/ruby.exe -r ./siteconf20180806-33956-l8y76h.rb extconf.rb
creating Makefile
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.
make failed, exit code 1
what i do is:
1. install ruby, path variable was set, version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32].
2. install rubygems, version: 2.7.7.
3. install MSYS2.
4. install jekyll, gem install jekyll, then the above error occurs and i'm not sure the reason.
i have tried to install devkit and it not works, i think my ruby version is 2.5+, so don't need devkit and i have uninstalled it.
Anyone could help me?

Although they made the Ruby+DevKit an "optional" download for the RubyInstaller on Windows, if you plan to install gems, it is practically a necessity. A large percentage of the most popular gems are C extension that will need built on your machine when being installed.
The DevKit is a handy toolchain that supplies everything you need for this to be done, automatically without you needed to do anything more than type gem install XXXXX. Without it, you either cannot use C extension gems, or must have already installed MSYS and MingW, have them configured properly, which is all not a user-friendly experience, even for those who familiar with the process.
So even if DevKit is optional, it is still required to make the most of Ruby on Windows.

Solution re-install ruby with rubyinstaller-devkit-2.5.5-1-x64
and issue
gem install bundler
gem install jekyll

I got the same error message. It turned out that the culprit was the ffi gem. I got it to work using this solution.

I had the same issue. I was able to resolve it (in Windows 11 x64) via:
winget install -e --id RubyInstallerTeam.RubyWithDevKit
(I.e., reinstall Ruby with the DevKit)

Related

Cannot install json gem on Mac

I'm not able to install json gem on my M1 MacBook. This is the command I'm running.
sudo gem install json -v '2.6.2'
This is the error I'm getting. I'm guessing it because it's picking up Xcode 14.1 Beta 3, but I'm not sure how to have it use a different version of Xcode or if that's the problem.
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20221018-37799-1wcwkww.rb extconf.rb
creating Makefile
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
In file included from ./../fbuffer/fbuffer.h:5:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/json-2.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/json-2.6.2/gem_make.out
The issue here is:
Assuming you're trying to install a modern 2.x version of JSON, this error is because it can't see the ruby development tools.
This is because MacOS doesn't include ruby development tools for its base-level version of ruby. That version of ruby is used for some very core-level things on Mac and they lock it down pretty intensely.
The solution is to use rbenv to install a new, user-controlled copy of ruby. This answer has a good step-by-step of how to do that, but the TLDR; is get brew, run brew install rbenv ruby-build, and then run rbenv install 2.6.10 && rbenv global 2.6.10 && rbenv rehash. Then restart your terminal.
Now gem install commands should target the copy of ruby you just installed. (You can validate this by running ruby --version and making sure it lists the version you installed in step 3.) This should fix your issue installing json, whether via gem install or bundle install.
resolved by CocoaPods/CocoaPods#10286
curl -sSL https://get.rvm.io | bash -s stable
close and reopen terminal
rvm install ruby#latest
rvm use ruby-3.0.0 --default
This issue was already reported here, https://github.com/rubygems/bundler/issues/4462.
Can you try bundle update && bundle install.
bundle update will install all of your dependencies, but if you dont want to update all dependencies, try bundle update json only.

ruby- packetgen installation gives gem install error

I'm trying to install packetgen, a library for crafting and manipulating network packets. I followed all the instructions, and installed all the necessary libraries. However, when I ran sudo gem install packetgen
to install it on my Linux machine it raised an error:
ERROR: Error installing packetgen:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pcaprub-0.12.4/ext/pcaprub_c
/usr/bin/ruby2.3 -r ./siteconf20181009-29130-us1azm.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/pcaprub-0.12.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0 /pcaprub-0.12.4/gem_make.out [here][1]
I ran the command as sudo, but got the same error. Does anyone know what I'm doing wrong here? The link to installation instructions is here.
Don't use sudo gem install but rather it is highly recommended that you use a ruby version manager, probably RVM, for more reasons why, see 'sudo gem install' or 'gem install' and gem locations
Based on your error it looks like you're trying to use your system ruby which will likely have permission and/or library dependency issues. These are easily solved by using a version manager which has many advantages including the ability to use different ruby versions on the same system and not having to use sudo or root level installs of gems.
You can install RVM from here
Instructions on gem link you posted do say gem depends on sudo apt install libpcap-dev which is a system lib your gem needs to build. I assume you did that step already right?

installation of jekyll failed - Windows

I am trying to install jekyll on a 32 bit windows 7 PC . I downloaded ruby installer-32 bit and 32 bit devkit and extracted un ruby install folder.i got some ssh error which i resolved by temporarily switching to http instead of https and then updated gems as well as installed bundler using
gem install bundler
however gem install jekyll gives following error
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
C:/Ruby21/bin/ruby.exe -r ./siteconf20150109-5804-1k3wbva.rb extconf.rb
No such file or directory - C:/Ruby21/bin/ruby.exe -r ./siteconf20150109-5804-1k
3wbva.rb extconf.rb 2>&1
Gem files will remain installed in C:/Ruby21/lib/ruby/gems/2.1.0/gems/fast-stemm
er-1.0.2 for inspection.
Results logged to C:/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/fas
t-stemmer-1.0.2/gem_make.out
You need to install the Ruby DevKit to fix the error you're seeing. Any sane Ruby install has the ability to build stuff on the fly.
I would start with Julian Thilo's awesome instructions for installing Jekyll on Windows:
Run Jekyll on Windows
If you are installing Ruby only for the purpose of running Jekyll, PortableJekyll will give you a full working Jekyll install in < 5 minutes.
Happy Jekylling...
I tried the same thing on 3 systems and found out that installing ruby gems fixed the issue .. so for anyone coming back at this question , this is how you install jekyll on a windows pc:
1.download and install ruby.
2.download devkit extract in to a folder(preferably inside ruby installation dir) and type in cmd window while in your devkit dir :
ruby dk.rb init
ruby dk.rb install
3.download and install gems by
ruby setup.rb
4. finally :
gem install bundler
gem install jekyll
*bundler is a jekyll dependency
I had the same issue on Windows 10 after installing Ruby+Devkit 2.5.X (x64) with the Windows installer.
The reason was that I changed the default path in the installer and had spaces in the path name. Apparently some make scripts do not like that.
Reinstalling to a path without any spaces fixed the issue.
Also see this related issue on github.
I failed to install "gem install jekyll bundler" when ruby was installed in "c:\program files\Ruby26-x64". After I reinstalled ruby on c:\Ruby26-x64 everything went ok. Seems like installation fails to parse path with blank

Failed to install Jekyll using Gem in Ruby: redcarpet-3.2.0 Makefile:238 error: Multiple target patterns

I'm failing to install Jekyll using gem in Ruby. Here's the output messages:
D:\Ruby21\bin>gem install jekyll
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
D:/Ruby21/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR=" clean
Makefile:238: *** multiple target patterns. Stop.
make "DESTDIR="
Makefile:238: *** multiple target patterns. Stop.
make failed, exit code 2
Gem files will remain installed in D:/Ruby21/lib/ruby/gems/2.1.0/gems/redcarpet-3.2.0 for inspection.
Results logged to D:/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/redcarpet-3.2.0/gem_make.out
D:\Ruby21\bin>
Unlike the other issue here, where the error breaks in the Makefile on line 222, mine breaks in the Makefile on line 238.
I can tell it has nothing to do with spaces in my installation path (since I installed Ruby in the root of my D drive). But anything from there is beyond my scope.
I'm using Windows Vista x86. I have installed Ruby 2.1.0 stable.
Does anyone know how to fix this?
Nevermind, I didn't solve the problem, but rather I used a workaround.
I installed Cygwin-x86 on my laptop, then installed Ruby and Rubygem, finally installed Jekyll and managed to go past the redcarpet-v3.2.0 build error.
To install Jekyll in Cygwin:
Run cygwin-setup.exe.
Install appropriate packages: Ruby, rubygem, make, gcc, git, libxslt, libxml2. Some more packages may be required here.
Install jekyll using gem install jekyll. Wait.
Type in command: vim ~/.bashrc
Scroll to the end and add export PATH=$PATH:".gem/ruby/gems/jekyll-2.4.0/bin"
That's how the Jekyll is installed on Cygwin.
Later on, you may need the following:
Subversion
bzip2
apt-cyg
patch
curl
rvm
jemoji
jekyll-sitemap
And have to do a lot of ~/.bashrc editing, calling source $HOME/path/to/rvm and PATH fixing.

librarian-puppet fails to install on windows

I am new to puppet. I am trying to install librarian-puppet in my windows system. I have followed the following installation steps before I started to install librarian-puppet :
Download and install puppet from the windows msi file from https://downloads.puppetlabs.com/windows/ (NOT gem install puppet).
You must run everything from the "Start Command Prompt with Puppet" not a normal Windows Command prompt.
Before installing librarian-puppet the the Ruby DevKit is needed:
a. Select "Start Command Prompt with Puppet" to go to a Command Windows.
b. Download and install devkit from http://rubyinstaller.org/downloads
c. In the devkit directory run “ruby dk.rb init”.
d. Edit the config.yml generated and add the the path of the ruby install for puppet
(it will be /sys/ruby).
e. run “ruby dk.rb install” to bind it to the puppet ruby installation.
and finally I did:
gem install librarian-puppet
But the error I get is:
ERROR: Error installing librarian-puppet:
ERROR: Failed to build gem native extension.
and the output of execution looks like this:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing librarian-puppet:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.
1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/ge
nerator/gem_make.out
Am I missing something here ? Any help would be appreciated.
If you install librarian-puppet 1.1.x or later it should not require the json gem that fails to build

Resources