I'm having a devil of a time installing Nokogiri on Ubuntu 12.04. I use rbenv.
$ gem install nokogiri -v '1.6.1'
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1/.autotest
$ sudo gem install nokogiri -v '1.6.1'
ERROR: Error installing nokogiri:
nokogiri requires Ruby version >= 1.9.2.
$ rbenv sudo gem install nokogiri -v '1.6.1'
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/home/deploy/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb
Gem files will remain installed in /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
$ sudo ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
$ rbenv sudo ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
$ echo $PATH
/home/deploy/.rbenv/bin:/home/deploy/.rbenv/bin:/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
It seems like I need some way of having sudo ruby -v give me 2.0.0. What am I missing?
You shouldn't need sudo when you do gem install with rbenv. Unfortunately, the ownership is usually not correct for the .rbenv directory on a new install.
Do this first to set your permissions correctly:
sudo chown -R $USER "$HOME/.rbenv"
Then go ahead and just run the install again:
gem install nokogiri -v '1.6.1'
It should work without sudo.
This works fine, but make sure to restart your terminal window after running sudo chown.
sudo chown -R $USER "$HOME/.rbenv"
# close terminal, then run the gem install
gem install nokogiri
Related
I'm trying to install the gem selenium-webdriver on Ubuntu 19.04 but I keep getting this error:
sudo gem install selenium-webdriver
Building native extensions. This
could take a while... ERROR: Error installing selenium-webdriver:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/childprocess-1.0.1/ext /usr/bin/ruby2.5 mkrf_conf.rb
current directory: /var/lib/gems/2.5.0/gems/childprocess-1.0.1/ext
/usr/bin/ruby2.5 -rrubygems
/usr/share/rubygems-integration/all/gems/rake-12.3.1/exe/rake
RUBYARCHDIR\=/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/childprocess-1.0.1
RUBYLIBDIR\=/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/childprocess-1.0.1
/usr/bin/ruby2.5: No such file or directory --
/usr/share/rubygems-integration/all/gems/rake-12.3.1/exe/rake
(LoadError)
rake failed, exit code 1
Gem files will remain installed in
/var/lib/gems/2.5.0/gems/childprocess-1.0.1 for inspection. Results
logged to
/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/childprocess-1.0.1/gem_make.out
I have tried
sudo gem update --system
sudo apt install ruby-dev
sudo apt install build-essential
sudo apt install gcc
sudo apt install make
ruby -v ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
gem -v 3.0.3
I had to do this
sudo gem pristine rake
Restoring gems to pristine condition... Cached gem for rake-12.3.1 not
found, attempting to fetch... Fetching rake-12.3.1.gem Restored
rake-12.3.1
I wanna use the bundler, but after I installed rbenv, ruby and bundler, it still tells me command not found.
$ rbenv version
2.2.3 (set by /Users/khlee/.rbenv/version)
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
$ export GEM_HOME=$HOME/Software/ruby
$ gem install bundler
Successfully installed bundler-1.12.5
Parsing documentation for bundler-1.12.5
1 gem installed
$ rbenv rehash
$ bundle install
-bash: bundle: command not found
Execute below command and check list of gem in gemset:
rbenv gemset list
May be budler gem is not installed in current gemset.
I have Ruby v2 installed:
$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin11.0]
but I get this error on multiple gems when I run:
$ sudo gem update
What's the problem and how do I fix it?
EDIT 1:
$ gem update
Updating installed gems
Updating actionmailer
Fetching: activesupport-4.1.8.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/1.8 directory.
EDIT 2:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/user/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
$ rvm info
-bash: rvm: command not found
The gem env was using an old version of ruby. I completely removed the gems via
gem list | cut -d" " -f1 | sudo xargs gem uninstall -aIx
(keep this terminal tab open so you know which gems you had and you can reinstall them) then opened a new terminal tab and then removed gem by doing
$ which gem
/usr/bin/gem
$ cd /usr/bin && sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem gem1.8.7 && sudo rm gem
I symlinked gem to gem1.8.7 if I want to use it later on.
Then I followed directions here https://rubygems.org/pages/download to reinstall gem with the latest ruby version, in my case Ruby 2.1.2p95.
If I try to install nokogiri, I receive the following error:
rvmsudo gem install nokogiri
ERROR: Error installing nokogiri:
nokogiri requires Ruby version >= 1.9.2.
If I check my ruby version, it tells me I am running ruby1.9.3
ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]
If I use printenv, these are my env variables:
rvm_bin_path=/home/jenkins/.rvm/bin
GEM_HOME=/home/jenkins/.rvm/gems/ruby-1.9.3-p448#nokogiri
SHELL=/bin/bash
TERM=xterm-color
IRBRC=/home/jenkins/.rvm/rubies/ruby-1.9.3-p448/.irbrc
HUSHLOGIN=FALSE
MY_RUBY_HOME=/home/jenkins/.rvm/rubies/ruby-1.9.3-p448
USER=jenkins
rvm_path=/home/jenkins/.rvm
L1=-
rvm_prefix=/home/jenkins
MAIL=/var/mail/jenkins
PATH=/home/jenkins/.rvm/gems/ruby-1.9.3-p448#nokogiri/bin:/home/jenkins/.rvm/gems/ruby-1.9.3-p448#global/bin:/home/jenkins/.rvm/rubies/ruby-1.9.3-p448/bin:/home/jenkins/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
PWD=/home/jenkins
LANG=C
rvm_version=1.21.3 (stable)
SHLVL=1
HOME=/home/jenkins
LOGNAME=jenkins
GEM_PATH=/home/jenkins/.rvm/gems/ruby-1.9.3-p448#nokogiri:/home/jenkins/.rvm/gems/ruby-1.9.3-p448#global
install_flag=1
RUBY_VERSION=ruby-1.9.3-p448
_=/usr/bin/printenv
I have some pretty bad luck with RVM and rather than break my entire installation, I thought I'd ask here.
Why can't I proceed with the installation of nokogiri?
I'm on Debian.
Just try gem install nokogiri as you have RVM installed. See here Installing Nokogiri for other things to install with it.
Like below :
# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
gem install nokogiri
See my answer here for the part ERROR: While executing gem ... (Errno::EACCES) ` Permission denied
I have added an older version of nokogiri (1.5.11) to chef cookbook and it worked fine after OR manually add it on the server:
chef_gem "nokogiri" do
action :install
version "1.5.11"
compile_time false if respond_to?(:compile_time)
end
OR
/usr/local/ruby-1.9.3-p392/bin/gem install nokogiri --version=1.5.11
(use absolute path where u see the error; means /my_path/gem install nokogiri).
I am having issues installing the ScrAPI gem:
ERROR: Error installing scrapi:
ffi requires Ruby version >= 1.9.2.
I am running RVM and if I do ruby -v I get:
ruby -v
ruby 1.9.2p110 (2010-12-20 revision 30269) [i686-linux]
I am guessing you did
$ sudo gem install scrapi
sudo ruby -v
Unless you followed Wayne's sudo RVM install I'm guessing root uses a different ruby.