简体   繁体   中英

Can't install ruby on rails in ubuntu gnome 15.10

I am trying to install ruby on rails. I'm at version 2.3.0 for ruby and gem version of 2.5.1.

When I run the command gem install rails I get an error that says:

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/local/lib/ruby/gems/2.3.0 directory.

How can I fix this?

gem install tries to put files in "system-wide" directories. These are protected, such that only the root user can write into.

You have at least three possibilities:

  • sudo gem install ... , this will write the gem files into /usr/local/lib/ruby/gems/2.3.0
  • gem install --user-install , this will install the gem "locally" in your users home directory
  • apt-get install ruby-rails (not sure about the package name), which will install the ruby on rails version maintained by your distributions maintainers (Canonical).
  • install and use rvm or rbenv (and there might be other options). Afterwards gem install will usually just work and install the gems for your user only

While the rvm setup might be a tiny bit confusing for newbies, I recommend using that approach. It will make updating and installing ruby, gems and different versions of it really easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM