1

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.

vee
  • 38,255
  • 7
  • 74
  • 78
  • did y try `gem install libxml-ruby -v '3.0.0` and please include the result of that command – Fabrizio Bertoglio Aug 16 '17 at 05:06
  • @FabrizioBertoglio: I've tried that and this is the error I'm receiving: `code`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`code` – George Mikhail Aug 17 '17 at 00:50

1 Answers1

2

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?

Fabrizio Bertoglio
  • 5,890
  • 4
  • 16
  • 57
  • Thank you for the detailed reply. I will work on installing rbenv on my mac tonight. In the meantime, I just wanted to point out that I did try running the installation with sudo and this is a portion of the error which it returns: `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.` – George Mikhail Aug 17 '17 at 02:28
  • @GeorgeMikhail you should locate `mkmf.log` and see what is the problem. Anyway you should not use `sudo`. `mkmf.log` should be saved somewhere inside the folders of `/Users/George/.rbenv`.. – Fabrizio Bertoglio Aug 17 '17 at 03:02