libxml issue when installing twilio-ruby gem - ruby-on-rails

I've been running in circles trying to install the 'twilio-ruby' gem in my rails app to no avail. Every time I try to bundle install I receive errors around libxml. Below is a part of the error I'm receiving when I add 'twilio-ruby' to the gem-file and try to bundle install:
Errno::EACCES: Permission denied # rb_sysopen - /Users/George/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/libxml-ruby-3.0.0/HISTORY
An error occurred while installing libxml-ruby (3.0.0), and Bundler cannot continue.
Make sure that `gem install libxml-ruby -v '3.0.0'` succeeds before bundling.
Trying to gem install libxml-ruby results in the error below:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/George/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/libxml-ruby-3.0.0/HISTORY
Any help that points me in the right direction would be much appreciated.

to install correctly rbenv follow the instructions on github for your operating system (Mac or Linux)
rbenv installation
While to better understand this problem, it is connected to security issues. Mac and Linux are Unix based system, where the user logs in and can execute commands on his home directory ~/<user>. If you try to execute a command to run a script in another directory like the root directory / or /bin, you will get an authorization error and you will need to run the command with sudo that stands for system user do.
For this reason, with linux you configure the ~/.bash_profile file
Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.
Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.
so that those command irb, gem, rake, rails when executed from the user they:
Search your PATH for an executable file named rake
Find the rbenv shim named rake at the beginning of your PATH
Run the shim named rake, which in turn passes the command along to rbenv
explanation of shims in rbenv
You can also solve easily this problem by running the command with sudo, but it is not reccommended, as you can read also from the below post where they have the same problem but with rvm,
Why do I get a "permission denied" error while installing a gem?

Related

Problem installing bundler, Says it installs, but then doesn't actually install

I am setting up a new system. I'm using rbenv instead of rvm because rvm changes the definition of 'cd' and that's just evil.
I've got the required version of ruby and rails (I think) installed, but bundler is causing problems:
turlingdrome$ gem install bundler
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/brianp/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/CHANGELOG.md
turlingdrome$ sudo gem install bundler
/usr/local/Cellar/rbenv/1.1.2/rbenv.d/exec/gem-rehash/rubygems_plugin.rb:6: warning: Insecure world writable dir /Users/brianp/work in PATH, mode 040777
Successfully installed bundler-2.0.1
Parsing documentation for bundler-2.0.1
Done installing documentation for bundler after 3 seconds
1 gem installed
turlingdrome$ sudo gem uninstall bundler
Gem 'bundler' is not installed
turlingdrome$ bundler install
Traceback (most recent call last):
2: from /Users/brianp/.rbenv/versions/2.5.3/bin/bundler:23:in `<main>'
1: from /Users/brianp/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/brianp/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException)
So, I tried using sudo once, and now I think that the permissions are super user... so I'm using sudo. no big deal.
Installing appears to work.
When I try to uninstall, it says it's not installed.
When I try to run it, it finds an executable, but then says it can't find an executable.
I'm using ruby 2.5.3 and rails (I think) 5.2.3.
Rails crashes with:
turlingdrome$ rails -v
/Users/brianp/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /Users/brianp/work in PATH, mode 040777
Traceback (most recent call last):
4: from bin/rails:3:in `<main>'
3: from bin/rails:3:in `require_relative'
2: from /Users/brianp/work/online-reporting/config/boot.rb:6:in `<top (required)>'
1: from /Users/brianp/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/brianp/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler/setup (LoadError)
which I assume is the same issue.
In case this matters, I'm on a mac.
rbenv works by inserting a directory of shims at the front of your PATH:
~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin
Through a process called rehashing, rbenv maintains shims in that directory to match every Ruby command across every installed version of Ruby—irb, gem, rake, rails, ruby, and so on.
Shims are lightweight executables that simply pass your command along to rbenv. So with rbenv installed, when you run, say, rake, your operating system will do the following:
Search your PATH for an executable file named rake
Find the rbenv shim named rake at the beginning of your PATH
Run the shim named rake, which in turn passes the command along to rbenv
You messed up your rbenv installation.
1) Remove ruby installation outside rbenv
2) rvm implode
3) Clean up your $PATH env variable from ~/.bash_profile or ~/.bashrc
Remove any $PATH reference pointing to ruby, irb, gem or any folder including those bin executable. Consider commenting any $PATH statement from your bash_profile
# export PATH="$HOME/etc/bin:$PATH"
# leave the statement below
# export PATH="$HOME/.rbenv/bin:$PATH
The $PATH variable includes a list of folders:
echo $PATH
home/fabrizio/.rbenv/shims:/opt/android-studio/bin:~/.scripts/bin
if you run gem in your terminal
any .bin executable file included in home/fabrizio/.rbenv/shims or /opt/android-studio/bin is executable from any location in the terminal. When you run gem, the ruby gem command is executed instead of being intercepted from rbenv, because you installed ruby outside of rbenv.
UPDATE BASED ON YOUR FEEDBACK
You must have followed this step when installing ruby 2.5.0 without rbenv so remove from your ~/.bash_profile or ~/.bashrc the following line
PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"
or any other line which is adding /Users/brianp/.gem/ruby/2.5.0/bin to your $PATH, then uninstall ruby with apt.
Read the following information, additionally always check the location where gems are being installed with gem env:
$ gem env home
# => ~/.rbenv/versions/<ruby-version>/lib/ruby/gems/...
if the location from anywhere in the terminal is not under ~/.rbenv/ then you are installing the gems in the wrong locations.
LAST RESORT
Delete the gem folder with rm -rf ~/.gem, a similar approach to this post if you can not remove /Users/brianp/.gem/ruby/2.5.0/bin from your $PATH
SOLUTION FOR YOUR LAST ERROR
This error is caused from installing bundler 2.0
can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
you need to remove bundler 2.0 and install 1.9.0
Usage of rbenv is a good choice to manage ruby installation on Mac, but it seems that you finished up in a complete mess of broken rbenv/gem/rails/bundler installation and permissions. It it is not worth of fixing it, so I suggest to just get rid of rbenv, remove ~/.rbenv directory and install rbenv with brew again using this guide.
Other ways to check:
Run rbenv-doctor
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Remove ~/.rbenv directory, run rbenv init again and install required version of Ruby
Check that which ruby and which gem points to appropriate location inside ~/.rbenv directory
Things to note:
rbenv and brew, as well as gem do not require sudo, so you should never use it with them
Do not forget to add eval "$(rbenv init -)" in your shell init script, e.g. echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
warning: Insecure world writable dir /Users/brianp/work in PATH, mode 040777
Looks like problem with access rights. Try this:
sudo chmod 755 /Users/brianp/work
Seems to be a permission issue on a folder.
permission denied # rb_sysopen -
/Users/brianp/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/CHANGELOG.md
I'd try to change permissions on the mentioned file / folder using chmod 755 /Users/brianp/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/
There are several posts which handle a similar topic, e.g. this.
Try to delete Gemfile.lockand try to install and use bundler again - I have just found that on Github:
Bundler 2 introduced a new feature that will automatically switch between Bundler v1 and v2 based on the lockfile [...] If you do, it can be fixed by installing the version of Bundler that is declared in the lockfile. This bug was fixed in RubyGems 3.0.0 but backports are now being prepared for previous major versions of RubyGems. We’ll let you know when they become available.
Can you try that?
gem install bundler --user-install

Permission Denied installing rabl gem

I am trying to install the spree gem but i am having a little trouble installing the gem. currently i am getting an error when trying to install the rabl(0.13.1) gem. I am getting a permission is denied . Wondering how i can fix this error so i can get back to finish installing spree.
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_file_s_symlink
Installing rabl 0.13.1
Errno::EACCES: Permission denied # rb_file_s_symlink -
(fixtures/ashared/views_rails_3/users/phone_number.json.rabl,
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rabl-0.13.1/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl)
An error occurred while installing rabl (0.13.1), and Bundler cannot continue.
Make sure that `gem install rabl -v '0.13.1'` succeeds before bundling.
In Gemfile:
spree was resolved to 3.4.1, which depends on
spree_backend was resolved to 3.4.1, which depends on
spree_api was resolved to 3.4.1, which depends on
rabl
C:\Users\Michael\Desktop\ruby\pen>gem install rabl -v '0.13.1
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_file_s_symlink - (fixtures/ashared/views_rails_3/users/phone_number.json.rabl, C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rabl-0.13.1/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl)
C:\Users\Michael\Desktop\ruby\pen>gem install
ERROR: While executing gem ... (Gem::CommandLineError)
Please specify at least one gem name (e.g. gem build GEMNAME)
C:\Users\Michael\Desktop\ruby\pen>uby/gems/2.4
'uby' is not recognized as an internal or external command,
operable program or batch file.
You can fix it by running your terminal on windows ( "Start Command Prompt with Ruby", "Git Bash" or similar ) as administrator.
If anyone runs into this problem in a Windows environment (windows 10),
use start command prompt with ruby as administrator
and run bundle update
First of all, I would recommend you to use bundler for automatic dependencies resolving.
Regarding your problem, I believe the root cause is here: Permission denied # rb_file_s_symlink - (fixtures/ashared/views_rails_3/users/phone_number.json.rabl
You should check permissions for this file and probably fix them. Because your current user does not have enough rights to access it.
And the last, but not the least, try switching to linux/mac. Windows is really not suitable for productive Ruby developemnt.
Just had this problem when trying to install the Spree gem on ruby on rails.
This was done on Rails 5.1.4, running Ruby ruby 2.3.3p222
This error occurs when you don't have admin rights.
Firstly, locate cmd and then right click on it and click on 'Run as administrator'.
Log in with the appropiate credentials and then when the cmd pops up, run the command again
gem install rabl -v '0.13.1'
And it should be successful!
In mac, I am facing similar issue and fixed by answer here: https://nanxiao.me/en/fix-permission-denied-rb_file_s_symlink-error-of-installing-homebrew/
I have pasted the command in case the link stops working.
sudo chown -R $(whoami) $(brew --prefix)/*

Can't Install Bundler, no permissions

Im using Ubuntu 15.10. This is the code I write in the terminal
gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.1.0 directory.
Why is it trying to install it there? of course it doesn't have permissions to install it in the root directory. If I try the same command like this sudo gem install bundler it works. But it is not supposed to be installed as sudo, it gives me problems when creating a new Rails app. What should I do?
You should probably start by running gem env and look at your default environment.
You can change the default installation directory by exporting a different GEM_HOME:
export GEM_HOME=$HOME/.gem/

Permission Error When Trying To Install Rails (OSX)

I am new to programming and am trying to get rails installed on my terminal. I have been following instructions from a friend, installing the xcode command line tools, homebrew, git, rbenv, ruby-build, ruby gems, ruby, and postgres. But whenever, I try $gem install rails, I get the following:
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ gem install rails
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
This is especially frustrating because when I run $gem list, it says I have rails 3.2.18. Which is peculiar, because when I run $rails v$, it tells me I have Rails 4.2.0.
When I try to use rails rails my new_app
Errno::EACCES: Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
An error occurred while installing rails (4.2.0), and Bundler cannot continue.
Make sure that `gem install rails -v '4.2.0'` succeeds before bundling.
run bundle exec spring binstub --all
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/shared_helpers.rb:83: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
bundler: command not found: spring
Install missing gem executables with `bundle install`
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ bundle install
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/vendor/thor/shell/basic.rb:355: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
Could not locate Gemfile or .bundle/ directory
This is really frustrating, especially for someone new to programming such as myself, so I am seeking help from anybody who might know what is wrong.
Your rbenv installation was incorrectly installed as it had elevated privileges which caused your user account to not have write access to ~/.rbenv.
Issue the following command in order to take of ownership of the directory:
sudo chown -R Russell_Silver ~/.rbenv
Note that some users may have a different rbenv directory, e.g. /usr/local/var/rbenv. This would take the place of ~/.rbenv in the above command.

Error during Installing Rails in Ubuntu 10.04

First I installed rvm for multi-user using script
\curl -L https://get.rvm.io | sudo bash -s stable
and I added users to rvm group.
and rvm seems worked fine. so I installed ruby 1.9.3 and set 1.9.3 as default
and now I tried to install rails with command
gem install rails
It seems worked fine, but when fetching json-1.7.6.gem and an error occurs.
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
creating Makefile
make
sh: make: Permission denied
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6/ext/json/ext/generator/gem_make.out
So I thought it would be related with permission, so I tried
sudo gem install rails
but then this error occurs.
sudo: gem: command not found
What should I do?
use sudo as follows..
sudo gem install rails
Updated Answer:
our $PATH variable needs to include the exact path to your Ruby's bin directory. Adding a directory to the PATH does not include it's subfolders. Try adding the bin directory via:
export PATH=$PATH:/home/adam/.gem/ruby/1.8/bin
or if you installed the gem using sudo:
export PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
You might want to add this to your .bashrc file, so that you don't have to set this manually every time your open up a new bash.
you can use rvmsudo to run sudo commands. But you should really be using Gemfiles to install gems using Bundler.

Resources