Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to install psych 5.0.1 on Ubuntu with any Ruby version #602

Closed
ahangarha opened this issue Dec 19, 2022 · 2 comments
Closed

Fail to install psych 5.0.1 on Ubuntu with any Ruby version #602

ahangarha opened this issue Dec 19, 2022 · 2 comments

Comments

@ahangarha
Copy link

I just tried to install psych 5.0.1 in a clean project and I couldn't. I tried this on Ruby version 2.7.5, 2.7.7 and 3.1.2. All fail. Since the minimum required ruby version is 2.4, I expect to not have any issue. I do this on Ubuntu machine. I also have failure in CI with again Ubuntu image.

The error with Ruby 2.7.5:

➜  test-psych-5.0.1-ruby-2.7.5 bundle add psych --version 5.0.1
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/........
Using bundler 2.1.4
Using stringio 3.0.4
Fetching psych 5.0.1
Installing psych 5.0.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/sama/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/psych-5.0.1/ext/psych
/home/sama/.rbenv/versions/2.7.5/bin/ruby -I /home/sama/.rbenv/versions/2.7.5/lib/ruby/2.7.0 -r
./siteconf20221219-115915-pwmisp.rb extconf.rb
checking for yaml.h... no
yaml.h not found
*** 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=/home/sama/.rbenv/versions/2.7.5/bin/$(RUBY_BASE_NAME)
	--with-libyaml-source-dir
	--without-libyaml-source-dir
	--with-yaml-0.1-config
	--without-yaml-0.1-config
	--with-pkg-config
	--without-pkg-config
	--with-libyaml-dir
	--without-libyaml-dir
	--with-libyaml-include
	--without-libyaml-include=${libyaml-dir}/include
	--with-libyaml-lib
	--without-libyaml-lib=${libyaml-dir}/lib

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

  /home/sama/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/psych-5.0.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/sama/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/psych-5.0.1
for inspection.
Results logged to
/home/sama/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/psych-5.0.1/gem_make.out

An error occurred while installing psych (5.0.1), and Bundler cannot continue.
Make sure that `gem install psych -v '5.0.1' --source 'https://rubygems.org/'` succeeds before
bundling.

In Gemfile:
  psych

and this is the content of the mentioned mkmf.log:

package configuration for yaml-0.1 is not found
find_header: checking for yaml.h... -------------------- no

"gcc -o conftest -I/home/sama/.rbenv/versions/2.7.5/include/ruby-2.7.0/x86_64-linux -I/home/sama/.rbenv/versions/2.7.5/include/ruby-2.7.0/ruby/backward -I/home/sama/.rbenv/versions/2.7.5/include/ruby-2.7.0 -I. -I/home/sama/.rbenv/versions/2.7.5/include    -g -O2 -fPIC conftest.c  -L. -L/home/sama/.rbenv/versions/2.7.5/lib -Wl,-rpath,/home/sama/.rbenv/versions/2.7.5/lib -L. -L/home/sama/.rbenv/versions/2.7.5/lib  -fstack-protector-strong -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/home/sama/.rbenv/versions/2.7.5/lib -L/home/sama/.rbenv/versions/2.7.5/lib -lruby  -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

"gcc -E -I/home/sama/.rbenv/versions/2.7.5/include/ruby-2.7.0/x86_64-linux -I/home/sama/.rbenv/versions/2.7.5/include/ruby-2.7.0/ruby/backward -I/home/sama/.rbenv/versions/2.7.5/include/ruby-2.7.0 -I. -I/home/sama/.rbenv/versions/2.7.5/include    -g -O2 -fPIC  conftest.c -o conftest.i"
conftest.c:3:10: fatal error: yaml.h: No such file or directory
    3 | #include <yaml.h>
      |          ^~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <yaml.h>
/* end */

--------------------

Am I missing something here?

@ahangarha
Copy link
Author

ahangarha commented Dec 19, 2022

It turned out that I need to install libyaml-dev on my machine so that this gem can get compiled. Is it meant to be this way?

Related PR: #541

@hsbt
Copy link
Member

hsbt commented Dec 20, 2022

You should install libyaml-dev for Psych 5.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants