0

I want to install Rails on Windows using the procedure described in the official Ruby guide.

When I enter

gem install rails

I get the error message:

Permission denied @ rb_sysopen - /var/lib/gems/3.2.0/gems/websocket-driver-0.8.0/CHANGELOG.md

Executing the command as root user does not help.

 ERROR: Failed to build gem native extension.

Does anyone have suggestions for resolving this issue?

New contributor
Kurt Hoffmann is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • Are you sure you actually followed this instructions? Meaning you installed mise and installed ruby from there? Commented Nov 15 at 13:59

2 Answers 2

0

Your OS user apparently has no write privilege on

/var/lib/gems/3.2.0/gems/websocket-driver-0.8.0/CHANGELOG.md

In order to fix it, you need to grant your OS user the necessary privileges over /var/lib/gems/3.2.0 or do it with a user who has access there, like a sudoer:

sudo gem install rails
Sign up to request clarification or add additional context in comments.

2 Comments

does not work as a sudoer. runs in another errors ..see post
"This error indicates that during the installation of a gem, the build process for compiling native extensions (typically C or C++ code) failed. This often happens because the gem relies on system-level libraries and tools that are either missing or incorrectly configured on your machine." fastruby.io/blog/how-to-fix-gem-ext-error.html
0

Often, a user might bump into permissions errors when trying to install gems on the same Ruby version that came installed on your OS. That version is usually "protected", it's meant to be used for common operations required by your system and you'd be better off avoiding to rely on it for your apps. Technically, you could do some workarounds, like sudoing the commands to force them to run, but it's not recommended to do so as you can end up messing up with basic configs.

The recommended way is to install Ruby through a package manager (such as Mise, as recommended the official docs link you shared in your original message).

By doing so, you'll install a Ruby version that's isolated from your OS and you should then have permissions to manipulate it as you wish.

1 Comment

I'm not sure why this was down-voted. Mise is an excellent choice for managing the installation of many languages without conflicting with the OS-shipped version of Ruby, which you should ABSOLUTELY not touch if you don't know what you're doing (and probably even still shouldn't).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.