bundle install using wrong ruby with rvm when building native extension? - ruby

I'm using bundle install to install rest-client. It's failing with the following:
$ bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing unf_ext 0.0.7.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20180115-9722-1iow75n.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 /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.4/gem_make.out
Installing mime-types-data 3.2016.0521
Installing netrc 0.11.0
Using bundler 1.11.2
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
I'm using rvm, which appears to be working correctly, if I'm reading the output from rvm info right.
which ruby reports /home/roger/.rvm/rubies/ruby-2.3.4/bin/ruby, which looks right.
I found Install ruby headers with rvm, but I have Ruby headers in (apparently) the correct place:
$ ruby -rmkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]'
/home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
$ ls /home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
ruby/ ruby.h x86_64-linux/
In the output from bundle, I see /usr/bin/ruby2.3, which looks suspicious.
It's looking in the wrong place for Ruby header files. How do I get it to use the RVM-installed ones?

I was using the wrong bundle.
$ which bundle
/usr/bin/bundle
Either the one included in Ubuntu 16.04 is old, or using the system-installed bundler doesn't work with rvm-installed Ruby.
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/bin/bundle
That looks better.
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Lesson learned: when using rvm, remember to gem install bundler as well.

Related

jekyll build error unknown encoding name "chunked\r\n\r\n25"

I am trying something simple. Using Jekyll with Bundler. The first thing to do is create a new directory for your project and runĀ  bundle init. This creates a new Bundler project (by creating an empty Gemfile).
mkdir my-jekyll-website
cd my-jekyll-website
bundle init
bundle config set --local path 'vendor/bundle'
bundle add jekyll
The last command gives me an issue.
C:\Users\***\Documents\LEARNING\web stuff\Jekyll\my-jekyll-website>bundle add jekyll
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching public_suffix 4.0.6
Installing public_suffix 4.0.6
Fetching addressable 2.7.0
Installing addressable 2.7.0
Using bundler 2.1.4
Fetching colorator 1.1.0
Installing colorator 1.1.0
Fetching concurrent-ruby 1.1.7
Installing concurrent-ruby 1.1.7
Fetching eventmachine 1.2.7 (x64-mingw32)
Installing eventmachine 1.2.7 (x64-mingw32)
Fetching http_parser.rb 0.6.0
Installing http_parser.rb 0.6.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: C:/Users/****/Documents/LEARNING/web
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r
./siteconf20200925-7100-x9bvnr.rb extconf.rb
creating Makefile
current directory: C:/Users/***/Documents/LEARNING/web
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean
current directory: C:/Users/***/Documents/LEARNING/web
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
generating ruby_http_parser-x64-mingw32.def
compiling ruby_http_parser.c
x86_64-w64-mingw32-gcc.exe: error:
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser:
No such file or directory
make: *** [Makefile:244: ruby_http_parser.o] Error 1
make failed, exit code 2
Gem files will remain installed in C:/Users/***/Documents/LEARNING/web
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.6.0
for inspection.
Results logged to C:/Users/***/Documents/LEARNING/web
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/extensions/x64-mingw32/2.6.0/http_parser.rb-0.6.0/gem_make.out
An error occurred while installing http_parser.rb (0.6.0), and Bundler cannot
continue.
Make sure that `gem install http_parser.rb -v '0.6.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
jekyll was resolved to 4.1.1, which depends on
em-websocket was resolved to 0.5.2, which depends on
http_parser.rb
What am I missing? Why is this happening?
When I run,
gem install http_parser.rb -v '0.6.0' --source 'https://rubygems.org/'
I get the following output,
http://rubygems.org' Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed http_parser.rb-0.6.0
Parsing documentation for http_parser.rb-0.6.0 unknown encoding name "chunked\r\n\r\n25" for ext/ruby_http_parser/vendor/http-parser-java/tools/parse_tests.rb,
skipping
Done installing documentation for http_parser.rb after 1 seconds
1 gem installed
Any pointers that will help me out of this?
I am running this on a Windows 10 laptop.
The code editor is VS Code and the Jekyll version is 4.1.1.
I just had the same problem on windows 10. In my case, the issue seemed to be caused by my Windows path including a folder with a space in its name and I see that you were in the same position ("web stuff"). Note the wording of the error - it only includes the section of the path following the space. In my case, moving the installation to a different folder without a space in the name fixed the problem.
compiling ruby_http_parser.c
x86_64-w64-mingw32-gcc.exe: error:
stuff/Jekyll/my-jekyll-website/vendor/bundle/ruby/2.6.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser:
No such file or directory
make: *** [Makefile:244: ruby_http_parser.o] Error 1
make failed, exit code 2
I guess that the compilation stage has failed to quote the name of the file to compile. I'm not a Ruby or Jekyll developer and don't know where to log that issue.

"bundle update" not working and installing in older version directory

In my jekyll folder, jekyll serve didn't work, showed missing dependencies.
On running bundle update in my jekyll site folder, it shows an error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.10.9/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20200629-9481-3yqsb7.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.5.0/gems/nokogiri-1.10.9 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-
1.10.9/gem_make.out
An error occurred while installing nokogiri (1.10.9), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.9' --source 'https://rubygems.org/'` succeeds
before bundling.
In Gemfile:
rails was resolved to 6.0.3.2, which depends on
actioncable was resolved to 6.0.3.2, which depends on
actionpack was resolved to 6.0.3.2, which depends on
actionview was resolved to 6.0.3.2, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
The issue is, it's trying to install gem in directory of older ruby version 2.5.0, which I have uninstalled. Currently, my ruby version is(installed using rmv):
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
The ruby in use also shows same:
$ which ruby
/usr/share/rvm/rubies/ruby-2.7.0/bin/ruby
The bundle directory in use:
$ which bundle
/home/devesh/.rvm/gems/ruby-2.7.0/bin/bundle
So how can I fix this issue, so that on bundle update, it generates gems in new gem directory?
Maybe you could try gem install bundler first, then do bundle update

Error installing nokogiri: invalid gem: package is corrupt

I'm trying to parse a website by using jekyll on my Debian x64 and I get a problem with this following gem nokogiri , in particular I've been required on install the version 1.8.5 , but as it was not working I attempted downloading the last version nokogiri (1.11.0.rc2) Manualy from the web and now I'm stuck with this error.
bundle exec jekyll serve
Could not find nokogiri-1.8.5 in any of the sources
Run `bundle install` to install missing gems.
bundle install
Bundler::GemspecError: Could not read gem at
/var/lib/gems/2.7.0/cache/nokogiri-1.8.5.gem. It may be corrupted.
An error occurred while installing nokogiri (1.8.5), and Bundler
cannot continue.
Make sure that `gem install nokogiri -v '1.8.5' --source
'https://rubygems.org/'` succeeds before bundling.
I think you don't have it's dependancy library libxml2 try running below code.
brew install libxml2
if not worked add nokogiri gem using below command
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]

Missing gem Faraday

I'm new to Ruby and I'm just trying to run a script. Firstly, when I try to bundle install it says:
Daniels-Air:Documents Daniel$ bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Rubygems 2.0.3 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Installing ffi 1.9.10 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
Gem files will remain installed in /var/folders/_r/8pxmrph95fj0km8h7sfkw9f40000gn/T/bundler20151216-21689-8jiqebffi-1.9.10/gems/ffi-1.9.10 for inspection.
Results logged to /var/folders/_r/8pxmrph95fj0km8h7sfkw9f40000gn/T/bundler20151216-21689-8jiqebffi-1.9.10/gems/ffi-1.9.10/ext/ffi_c/gem_make.out
Using multipart-post 2.0.0
Installing json 1.8.3 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
Gem files will remain installed in /var/folders/_r/8pxmrph95fj0km8h7sfkw9f40000gn/T/bundler20151216-21689-5mz4k9json-1.8.3/gems/json-1.8.3 for inspection.
Results logged to /var/folders/_r/8pxmrph95fj0km8h7sfkw9f40000gn/T/bundler20151216-21689-5mz4k9json-1.8.3/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
Using multi_json 1.11.2
Using rubyzip 1.1.7
Using websocket 1.2.2
Using bundler 1.11.1
An error occurred while installing ffi (1.9.10), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.10'` succeeds before bundling.
When I then try to execute the file anyway I come across the problem:
Could not find gem 'faraday' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
Where do I get this 'faraday' gem from? Should it have come with the code I am trying to run, or should I update something? Sorry if I got some terminology wrong, I'm very new to Ruby.
I've just realised all I needed to do was install the gem. Its made clear from the RubyGems.org library. Just typed:
sudo gem install faraday
to the terminal

gem check errors (registered but missing gems) after installing ruby 2.0.0-p0 with rbenv install

Everything works fine with my installation of ruby 1.9.3.
$ rbenv global 1.9.3-p385
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.1.0)
io-console (0.3)
json (1.5.4)
minitest (2.5.1)
rake (0.9.2.2)
rdoc (3.9.5)
$ gem check
$
However after I installed ruby 2.0.0 with rbenv install, some strange error messages showed up in gem check.
$ rbenv install 2.0.0-p0
Downloading openssl-1.0.1e.tar.gz...
-> https://www.openssl.org/source/openssl-1.0.1e.tar.gz
Installing openssl-1.0.1e...
Installed openssl-1.0.1e to /Users/gogao/.rbenv/versions/2.0.0-p0
Downloading ruby-2.0.0-p0.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
Installing ruby-2.0.0-p0...
Installed ruby-2.0.0-p0 to /Users/gogao/.rbenv/versions/2.0.0-p0
$ rbenv global 2.0.0-p0
$ rbenv rehash
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.0)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
test-unit (2.0.0.0)
$ gem check
Checking gems...
bigdecimal-1.2.0.gem has 1 problems
bigdecimal-1.2.0:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bigdecimal-1.2.0
io-console-0.4.2.gem has 1 problems
io-console-0.4.2:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/io-console-0.4.2
json-1.7.7.gem has 1 problems
json-1.7.7:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/json-1.7.7
minitest-4.3.2.gem has 1 problems
minitest-4.3.2:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/minitest-4.3.2
psych-2.0.0.gem has 1 problems
psych-2.0.0:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/psych-2.0.0
rake-0.9.6.gem has 2 problems
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rake-0.9.6.gem:
missing gem file /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rake-0.9.6.gem
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/specifications/rake-0.9.6.gemspec:
Spec file missing for installed gem
rdoc-4.0.0.gem has 2 problems
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rdoc-4.0.0.gem:
missing gem file /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rdoc-4.0.0.gem
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/specifications/rdoc-4.0.0.gemspec:
Spec file missing for installed gem
test-unit-2.0.0.0.gem has 2 problems
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/test-unit-2.0.0.0.gem:
missing gem file /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/test-unit-2.0.0.0.gem
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/specifications/test-unit-2.0.0.0.gemspec:
Spec file missing for installed gem
$
Is it a known bug? or am i doing something wrong?
For Ruby 2.0.0-p0, I also get similar warnings from gem check. However, I don't have issues at runtime with any of these gems. I suspect this might be a bug with Rubygems check command in 2.0.0.
I have similar errors. Passing options to compiler fix installation.
Before install readline and openssl with Homebrew.
RUBY_CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)
--with-openssl-dir=$(brew --prefix openssl)" rbenv install 2.0.0-p0
More info from Original Post

Resources