Troubleshooting Permission denied @ rb_sysopen when attempting to install an earlier version of Rails
It seems like your ruby
installation through rbenv
was made via sudo, which will create gem structure with root privileges.
So, when you perform a gem install rails
from a regular user, you won't have the privileges to write into gems directory, raising the permission denied error.
You can confirm the permission by running:
ls -la /Users/ayylmao/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/
Try to reinstall your ruby with you own user (without sudo) and the installation of rails or other gems will sould be fine.
when installing gems Error: Permission denied rb_sysopen Arch Linux
You are having a permissions issue attempting to open
/usr/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out
Running this will most likely install correctly, but you may want to fix whatever the permission issue is instead:
sudo gem install rails
Errno::EACCES: Permission denied @ rb_sysopen on http-parser 1.2.3
What should the permissions be?
Looking at my own rbenv installation,
- I own all files under
~/.rbenv
, and - directories under
~/.rbenv
aredrwxr-xr-x
(755) and - files are either
-rw-rw-r--
(664) or -rwxrwxr-x
(775), if they are meant to be executable.
Recommendation
Just reinstall everything :)
rbenv uninstall 3.0.1
rbenv install 3.0.1
bundle install
Ruby gem command fails with Permission denied @ rb_sysopen
You get this error when you run without sudo because you're using what some people refer to as "system" ruby on your computer; it's the default ruby that ships with macOS. If you run which ruby
it will most likely point to /usr/bin/ruby
(if you haven't installed rvm
, rbenv
, or another ruby version manager.
By default, system ruby (which includes the system gem
and bundler
commmands) points to a file location which requires sudo
to install to.
I recommend you don't run sudo to install gems; instead install a ruby version manager such as rvm (the most popular), rbenv (also a popular choice), or asdf (my preferred version manager because it manages more than just ruby, if you want to)
Once you install a ruby version manager per the instructions you should be able to install a more recent version of ruby (system ruby is 2.3.7, the most recent is 2.6.0). The version manager will also setup sane paths for your gem
and bundle
commands, pointing to paths where you have write privileges without using sudo
A ruby version manager is highly recommended because it won't interfere with any system dependencies which might rely on the system ruby version, and a version manager allows you to install multiple versions of ruby and switch between them for different projects.
Rails console access gets Permission denied @ rb_sysopen Error
It Looks like permission issue. I found 2 solutions. I hope one of them will solve your issue.
Looking at the error it seems like it is unable to access. We can try to give access by below command
sudo chmod -R 777 /Users/yannherveeaniman/.irb_history
(giving all access to file)OR
sudo chmod -R 777 /Users/yannherveeaniman
(giving all access to your folder)create/edit
~/.irbrc
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"credits - https://stackoverflow.com/a/52360668/18073270
Thank You for reaching out to this beautiful platform. Hopefully your issues will be resolved.
Regards.
Related Topics
How to Require Active Record Working Outside of Rails
Is There a Built-In Binary-Search in Ruby
Ruby SQLite3 Installation SQLite3_Libversion_Number() MACos Sierra
How to Get Sinatra to Auto-Reload the File After Each Change
How to Compare Versions in Ruby
Ruby and "You Must Recompile Ruby with Openssl Support or Change the Sources in Your Gemfile"
How to Serve Requests Concurrently with Rails 4
Add Method to an Instanced Object
Size, Length and Count in Rails
How to Automate Chrome Request Blocking Using Selenium-Webdriver for Ruby
Ruby 'Encode': "\Xc3" from Ascii-8Bit to Utf-8 (Encoding::Undefinedconversionerror)
Ruby 1.9 + Sinatra Incompatible Character Encodings: Ascii-8Bit and Utf-8
Base64 Photo and Paperclip -Rails
How to Install Ruby 2 on Ubuntu Without Rvm
How to Pass a Parameter for Gem Installation When I Run Bundle Install
Where's the Best Place to Define a Constant in a Ruby on Rails Application