简体   繁体   中英

Cannot install rails version 4.2.5 on Ubuntu in WSL when I have ruby 2.2.1 active. nokogiri requires Ruby version >= 2.3.0

Trying to install rails version 4.2.5 on Ubuntu in Windows Subsystem for Linux on Windows 10 when I have ruby 2.2.1 installed and active I get the following error:

~$ gem install rails -v 4.2.5
ERROR:  Error installing rails:
        nokogiri requires Ruby version >= 2.3.0.

I need these versions to collaborate on a project which uses these versions.

I started by installing WSL (1 not 2) on windows 10, then downloaded and installed Ubuntu Linux. Then I installed rbenv , updated dependencies, installed ruby 2.5.1 which was fairly easy. I had problems installing ruby 2.2.1 but got there after doing

$ sudo apt-get install -y libssl1.0-dev

to install an earlier version of libssl which ruby 2.2.1 needs.

I installed node.js and an earlier version of bundler using

$ gem install bundler -v 1.17.3

as trying

$ gem install bundler 

failed with a similar error.

(I also installed ruby 2.5.1 and rails 4.2.5 on top of it with few problems)

Trying various diagnostics showed rails was not installed for ruby 2.2.1

~$ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
  2.5.1

(but not in ruby 2.2.1, which is where I need it)

Looking at my files in windows File Explorer (only looking) I can see that while my ruby 2.5.1 gems include rails my ruby 2.2.1 files are incomplete and do not include rails.

I think the PATH is correct.

$ echo $PATH returns
/home/johnloughran/.rbenv/plugins/ruby-  build/bin:/home/johnloughran/.rbenv/shims:/home/johnloughran/.rbenv/bin:/usr/ 
local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local 
/games:/mnt/c/Program 
Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2019.522.0_ 
x64__79rhkp1fndgsc:  ........   :/snap/bin

I modified my .bashrc file to add various entries to the PATH which have been included above.

I repeated the whole process twice starting from scratch (uninstalling Ubuntu) with the same block at the end.

What is my best option here to try and continue?

Thanks Josien for your comments. In the first case my collaborators have these versions of Ruby and Rails working together, but its a few years now since they installed them. One, David, helped me by trying a fresh install of rails 4.2.5 on ruby 2.2.1 which ran into the same problem above with nokogiri.

He solved it by installing a lower version of nokogiri in a new test directory, which I repeated as:

test$ gem install nokogiri -v 1.9.1

This worked. Then I installed rails as

test$ gem install rails --version 4.2.5

At last .... it worked!!!! :-) To prove it I was able to get rails to return its version correctly.

test$ rails -v
Rails 4.2.5

Then I was able to create an app as

<working-directory>$ rails new learn-ruby

which works, almost, having hit another dependency problem, but hey ... that's programming!

Re your second comment I do not know enough about this stuff to know how relevant it is that this version of ruby is deprecated and the rails version is getting there too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM