We have a build pipeline in the Rails project: we bundle and test application in the test server and then we copy it (code with gems in vendor/) to the staging server and deploy it to a passenger server.
It used to work, but now I get following error in the apache.error.log:
WARNING: Nokogiri was built against LibXML version 2.7.6, but has dynamically loaded 2.6.26
/usr/local/rvm/rubies/ruby-1.9.2-p318/bin/ruby:
relocation error: /home/project/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/nokogiri.so:
symbol xmlNextElementSibling, version LIBXML2_2.7.3 not defined in file libxml2.so.2 with link time reference
and error 500 in the browser.
When I run webbrick on the staging server U get similar errors on first request. How could I solve it?
EDIT:
Stange thing with nokogiri version. The same binary loads different libxml version depending if I call it standalone or with bundle exec:
vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri -v
# Nokogiri (1.5.2)
---
warnings: []
nokogiri: 1.5.2
ruby:
version: 1.9.2
platform: x86_64-linux
description: ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]
engine: ruby
libxml:
binding: extension
compiled: 2.6.26
loaded: 2.6.26
$ bundle exec vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri -v
WARNING: Nokogiri was built against LibXML version 2.7.6, but has dynamically loaded 2.6.26
# Nokogiri (1.5.2)
---
warnings:
- Nokogiri was built against LibXML version 2.7.6, but has dynamically loaded 2.6.26
nokogiri: 1.5.2
ruby:
version: 1.9.2
platform: x86_64-linux
description: ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]
engine: ruby
libxml:
binding: extension
compiled: 2.7.6
loaded: 2.6.26
the error really says it all. you have a different version of LibXML on your local machine (where your gem was compiled) version 2.7.6 as on your server 2.6.26 either downgrade your development machine or build your gems on the server
I resolved the problem. I built libxml2 from source and then I configured bundler to use this new version:
bundle config build.nokogiri --with-xml2-dir=/usr --with-xslt-dir=/usr/local
(Now it I have a warning, because the version that is loaded is newer that the one that was used to built Nokogiri, but it's not a problem).
If the problem persists on a 64bit bare machine, I solved it updating zlib1g from 1.2.3 to 1.2.7:
$> aptitude update
$> aptitude install zlib1g
Related
I'm using a self-hosted chatwoot installation on AWS using ubuntu.
I'm upgrading the chatwoot version following the guide but when i want to precompile the assets, I run into an error
Your Ruby version is 2.7.0, but your Gemfile specified 3.0.2
But when i get the ruby version, it states that my version is already the same as specified in the Gemfile.
Screenshot of the problem
I'm kind of loss at this problem.
Thanks in advance.
You better install Ruby 2.7.0 for compatibility. The Ruby version in your local machine is different from the one declared in Gemfile.
If you're using rvm:
rvm install 2.7.0
rvm use 2.7.0
else if you're using rbenv:
rbenv install 2.7.0
rbenv local 2.7.0
I am on Windows and running Ruby 2.7.0.
When running gem install rails I get this error:
ERROR: Error installing rails:
The last version of nokogiri (>= 1.6) to support your Ruby & RubyGems was 1.10.9.
Try installing it with `gem install nokogiri -v 1.10.9` and then running the current command again
nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current ruby version is 2.7.0.0.
When I run gem install nokogiri -v '1.10.9' I get the same exact error.
I have installed gem install nokogiri -v 1.11.0.rc1 --pre , but I'm still getting the same errors.
$ nokogiri -v
# Nokogiri (1.11.0.rc1)
---
warnings: []
nokogiri: 1.11.0.rc1
ruby:
version: 2.7.0
platform: x64-mingw32
description: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
engine: ruby
libxml:
source: packaged
patches:
- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
- 0002-Remove-script-macro-support.patch
- 0003-Update-entities-to-remove-handling-of-ssi.patch
- 0004-libxml2.la-is-in-top_builddir.patch
compiled: 2.9.10
loaded: 2.9.10
libxslt:
source: packaged
patches: []
compiled: 1.1.34
loaded: 1.1.34
So, I understand that Ruby 2.7.0 is later than 2.7.dev, but I have the nokogiri gem installed.
Also, everything was working fine with Ruby 2.6.5. I did uninstall it, remove it from the Path, and restart my machine.
If anybody has any ideas I would love to hear them.
It seems that when you are trying to install nokogiri it installs a version which is not compatible with your ruby version and shows that error.
Even when you specify the version to install, it'll ignore the version number specified and install the latest one as shown in your error.
$ nokogiri -v
# Nokogiri (1.11.0.rc1)
---
warnings: []
nokogiri: 1.11.0.rc1
So try to make the gem makes the download itself for the currently installed ruby version.
gem install nokogiri --platform=ruby
PS This could take a while...
When I try to start my Rails server, I get the following error:
$ bundle exec rails s
Your Ruby version is 2.3.7, but your Gemfile specified ~> 2.3.8
I don't understand why that happens though, since I set Ruby to 2.3.8 both using Homebrew and using rbenv. 2.3.7 is the version of the system's ruby. I am using Mac OS 10.14.4.
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
$ rbenv version
2.3.8 (set by /Users/ceasar/foo/.ruby-version)
$ which -a ruby
/Users/ceasar/.rbenv/shims/ruby
/usr/local/opt/ruby#2.3/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
$ which -a bundle
/Users/ceasar/.rbenv/shims/bundle
/usr/local/bin/bundle
$ /usr/bin/xcodebuild -version
Xcode 10.2
Build version 10E125
$ brew list ruby#2.3
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/erb
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/gem
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/irb
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/rake
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/rdoc
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/ri
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/ruby
/usr/local/Cellar/ruby#2.3/2.3.8_1/include/ruby-2.3.0/ (25 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/libruby.2.3.0.dylib
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/pkgconfig/ruby-2.3.pc
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/ruby/ (1211 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/ (3 other files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/emacs/ (7 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/man/ (4 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/ri/ (13487 files
$ bundle env | head -n 40
## Environment
```
Bundler 2.0.1
Platforms ruby, x86_64-darwin-18
Ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
Full Path /Users/ceasar/.rbenv/versions/2.3.8/bin/ruby
Config Dir /Users/ceasar/.rbenv/versions/2.3.8/etc
RubyGems 2.5.2.3
Gem Home /Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
Gem Path /Users/ceasar/.gem/ruby/2.3.0:/Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
User Path /Users/ceasar/.gem/ruby/2.3.0
Bin Dir /Users/ceasar/.rbenv/versions/2.3.8/bin
Tools
Git 2.19.2
RVM not installed
rbenv rbenv 1.1.2
chruby not installed
```
## Bundler Build Metadata
```
Built At 2019-01-04
Git SHA d7ad2192f
Released Version true
```
## Bundler settings
```
build.libv8
Set for the current user (/Users/ceasar/.bundle/config): "--with-system-v8"
build.mysql2
Set for the current user (/Users/ceasar/.bundle/config): "--with-mysql-config=/usr/local/Cellar/mysql#5.7/5.7.24/bin/mysql_config"
path
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): "vendor/bundle"
disable_shared_gems
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): true
```
I don't see anything here which would make me think it shouuld be using 2.3.7.
I'm not sure what else to try.
How does Bundler decide which version of Ruby to use, and how can I configure it to use either rbenv or my homebrew Ruby installation?
How about to try to use 'rvm'?
rvm install 2.4.2
This command will install another version of ruby, 2.4.2
And you can simply check the versions which all you have as
rvm list.
After this, run the version which you wish as the below,
rvm <version> or rvm use <version>
Hope this will help you!
Summary: The wrong version of bundler causes the problem. Use a ruby version manager to install the needed ruby version. Then install the correct version of the bundler gem for your project.
Details: In my case I'm running a rails example on github that required an older version of ruby and bundler and got the error described.
To manage my different ruby versions, I'm using ruby-install and chruby both installed with homebrew.
I followed these steps to resolve the problem on macOS Catalina v10.15.7:
Resolution steps
% ruby-install 2.4.1
# open a new shell so chruby will find 2.4.1
% chruby 2.4.1
% which ruby
/Users/richardlogwood/.rubies/ruby-2.4.1/bin/ruby
% gem install bundler:1.16.1
% which bundle
/Users/richardlogwood/.gem/ruby/2.4.1/bin/bundle
% cd (to the rails project directory)
# Note: it's a rails project so there was a binstub
# for bundler, hence `bin/bundler` in the project directory*
% bin/bundler install
% rake db:{create,migrate}
% bin/rails s
Before running the above steps, the error messages told me which version of ruby and bundler I needed to install. The system bundler was the wrong version (I'm on a mac) and the initial error message using that version gave me the error below. Only after installing the needed bundler gem (see above) was the correct ruby version resolved (see above).
Errors before resolution
% bundle install
Your Ruby version is 2.6.3, but your Gemfile specified 2.4.1
% which ruby
/Users/richardlogwood/.rubies/ruby-2.4.1/bin/ruby
% which bundle
/usr/bin/bundle
Note, the required bundler version was indicated by this error message:
Could not find 'bundler' (1.16.1) required by your ... /Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.1`
I don't suggest using RVM instead of RBEnv. RBEnv is one of the most up-to-date solutions around, and most people stick with it.
Can you please try running gem update --system to update your bundler first.
Install Rbenv and run the following commands in your project directory to install 2.3.8:
rbenv install 2.3.8
rbenv local 2.3.8
bundle install --path=vendor/cache
I had rbenv installed and also installed Ruby manually at some point because of certain issues which I thought I cleaned up. But it seems I had /usr/local/bin/{bundle,bundler} still present which was evident when I did: which bundle that showed it's location not under shims (belonging to rbenv) so I simply had to remove these e.g. rm -rf /usr/local/bin/{bundle,bundler} and all was working again.
I'm using Ruby 1.9.3 with my Rails v3.2.19 application and I'm unable to run bundle because Nokogiri requires a Ruby version >= 2.1.0. At the moment I cannot upgrade my Ruby version and I really need to install Nokogiri otherwise my app won't run.
Besides the regular solutions using gem install, I've already tried the following command line with no success:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2
ERROR:
>Error installing nokogiri:
nokogiri requires Ruby version >= 2.1.0.
Is there a way that I can install Nokogiri using my current Ruby version?
Additional Info:
Rails version - 3.2.19
Ruby version - 1.9.3
Nokogiri version - 1.7.0.1
OS - CentOS 7
The last version of nokogiri to support Ruby 1.9.3 was 1.6.8.1, so you need to do something like
gem install nokogiri -v 1.6.8.1
First try update xcode command line tools xcode-select --install
Then try these steps https://github.com/sparklemotion/nokogiri/wiki/What-to-do-if-libxml2-is-being-a-jerk
Having a setup of
WEBrick 1.3.1
Ruby 2.2.2
Rails 3.2.22
5.6.22 MySQL
Yosemite 10.10.4
I am trying to run an old Project built on Ruby version 1.9.2 - Rails 2.2.3 - WEBrick 1.3.1 and once i type command : rails server i get an error :
Installing json 1.6.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
Could not find json-1.6.1 in any of the sources
Run bundle install to install missing gems
When i type 'bundle install' in the project directory i receive an error of :
An error occurred while installing json (1.6.1), and Bundler cannot continue.
Make sure that gem install json -v '1.6.1' succeeds before bundling.
What do i have to do in order to get this environment able to run this old project? Should i have to downgrade my Rails version .
Furthemore, by the time it fails to update gem json -v '1.6.1' , is there any other way to update it?
Eventually, i managed to run my old project by installing Ruby 1.9.3 with Rails 3.1.1. At first i thought that the problem was that
gem install json -v '1.6.1' was failing.
But the reason that caused the error on the first place was that :
You cannot install ruby 1.9.2p551 on Yosemite 10.10.4!!
Instead what i did was to
Install Ruby Version Management "RVM"
Install via RVM ruby -v1.9.3p551
Run command rvm use ruby-1.9.3-p551 in order to use this version
Run bundle install to load railties 3.1.1 gem
Run rails server on the "project" directory
Through these steps i am now able to view my application on browser !
Many thanks to jkeuhlen & boulder_ruby for the help.