Firstly, apologies for any inconsistencies: this is my first experience with Ruby and RoR.
I've been trying to install Rails for Ruby 2.4.5.
I am required to stick to Ruby 2.4.5, and I am given a Gemfile.lock file with a dependency on Rails 5.1.5.
Also i'm using rbenv for version management.
When trying the following:
gem install rails -v 5.1.5
I get the following error:
ERROR: Error installing rails:
racc requires Ruby version >= 2.5.
Any help would be greatly appreciated :)).
I am running a MacBook with an M1 Pro chip. This had created a few complications while installing Ruby, so I suspect this might be a potential reason?
I tried installing different versions of Rails, although this goes against the gemfile, but to no avail.
I tried to install the gemfile directly through Bundler, thinking maybe that'd install Rails, but got the following:
Fetching gem metadata from https://rubygems.org/.........
Using rake 12.3.0
Using concurrent-ruby 1.0.5
Using i18n 0.9.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.1.5
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Fetching nokogiri 1.8.2
Installing nokogiri 1.8.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2/ext/nokogiri
/Users/x/.rbenv/versions/2.4.5/bin/ruby -r ./siteconf20231026-14985-19u934u.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.7.
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.7.tar.gz into tmp/arm-apple-darwin23.0.0/ports/libxml2/2.9.7... OK
Running 'configure' for libxml2 2.9.7... OK
Running 'compile' for libxml2 2.9.7... ERROR, review
'/Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2/ext/nokogiri/tmp/arm-apple-darwin23.0.0/ports/libxml2/2.9.7/compile.log' to see
what happened. Last lines are:
========================================================================
int writtentot = 0;
^
encoding.c:2569:9: warning: variable 'output' set but not used [-Wunused-but-set-variable]
int output = 0;
^
7 warnings generated.
CC error.lo
CC parserInternals.lo
CC parser.lo
CC tree.lo
CC hash.lo
CC list.lo
CC xmlIO.lo
xmlIO.c:1357:52: error: use of undeclared identifier 'LZMA_OK'
ret = (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
^
1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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=/Users/x/.rbenv/versions/2.4.5/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to
complete compile task (RuntimeError)
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `chdir'
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `execute'
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in `compile'
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in `cook'
from extconf.rb:365:in `block (2 levels) in process_recipe'
from extconf.rb:257:in `block in chdir_for_build'
from extconf.rb:256:in `chdir'
from extconf.rb:256:in `chdir_for_build'
from extconf.rb:364:in `block in process_recipe'
from extconf.rb:262:in `tap'
from extconf.rb:262:in `process_recipe'
from extconf.rb:551:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/extensions/-darwin-23/2.4.0/nokogiri-1.8.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2 for inspection.
Results logged to /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/extensions/-darwin-23/2.4.0/nokogiri-1.8.2/gem_make.out
An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
rails was resolved to 5.1.5, which depends on
actioncable was resolved to 5.1.5, which depends on
actionpack was resolved to 5.1.5, which depends on
actionview was resolved to 5.1.5, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
Edit:
Running gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'
outputted the following:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2/ext/nokogiri
/Users/x/.rbenv/versions/2.4.5/bin/ruby -r ./siteconf20231026-11138-5eq46d.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.7.
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.7.tar.gz into tmp/arm-apple-darwin23.0.0/ports/libxml2/2.9.7... OK
Running 'configure' for libxml2 2.9.7... OK
Running 'compile' for libxml2 2.9.7... ERROR, review '/Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2/ext/nokogiri/tmp/arm-apple-darwin23.0.0/ports/libxml2/2.9.7/compile.log' to see what happened. Last lines are:
========================================================================
int writtentot = 0;
^
encoding.c:2569:9: warning: variable 'output' set but not used [-Wunused-but-set-variable]
int output = 0;
^
7 warnings generated.
CC error.lo
CC parserInternals.lo
CC parser.lo
CC tree.lo
CC hash.lo
CC list.lo
CC xmlIO.lo
xmlIO.c:1357:52: error: use of undeclared identifier 'LZMA_OK'
ret = (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
^
1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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=/Users/x/.rbenv/versions/2.4.5/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete compile task (RuntimeError)
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `chdir'
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `execute'
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in `compile'
from /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in `cook'
from extconf.rb:365:in `block (2 levels) in process_recipe'
from extconf.rb:257:in `block in chdir_for_build'
from extconf.rb:256:in `chdir'
from extconf.rb:256:in `chdir_for_build'
from extconf.rb:364:in `block in process_recipe'
from extconf.rb:262:in `tap'
from extconf.rb:262:in `process_recipe'
from extconf.rb:551:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/extensions/-darwin-23/2.4.0/nokogiri-1.8.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2 for inspection.
Results logged to /Users/x/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/extensions/-darwin-23/2.4.0/nokogiri-1.8.2/gem_make.out