2

I'm pretty deep into a project, I have deployed a version of it on heroku which demanded I update my ruby version to complete my setup. After successfully completing that process I went back to my project to continue development and tried to save some variables using

EDITOR='code --wait' rails credentials:edit

and I get...


➜  $EDITOR='code --wait' rails credentials:edit

=> Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

When I run the sudo command I get successful response but when I try to run EDITOR='code --wait' rails credentials:edit I get the same error.

I've tried to work through some solutions which lead me to try

gem install rails

but then I get this error:

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/3.0.0/gems/rails-6.1.3.2/README.md

As I can not save the variable or even start a new rails project I am pretty much stuck and will appreciate any suggestions or guidance.

  • How did you install Ruby? – Sebastián Palma May 12 '21 at 17:12
  • I used `rbenv install` – jsonmullings May 12 '21 at 17:14
  • Try updating the gems folder owner to your current user `sudo chown -R $USER /usr/local/lib/ruby/gems`. – Sebastián Palma May 12 '21 at 17:20
  • 2
    Looks like you've screwed up permissions with `sudo`. Since you're using `rbenv`, you should not need to run any ruby/gem installation commands with `sudo`. – Tom Lord May 12 '21 at 17:27
  • 1
    You could either try to fix all files/folders that you've messed up (as per the above suggestion), or completely uninstall ruby, then re-install it cleanly without `sudo`. – Tom Lord May 12 '21 at 17:28
  • I guess I'll uninstall it completely as the other solution still ends plays out like this: ` ~ gem install rails Successfully installed rails-6.1.3.2 1 gem installed ~ rails -v Rails is not currently installed on this system. To get the latest version, simply type: $ sudo gem install rails` – jsonmullings May 12 '21 at 17:52
  • Does this seem like a good set of instructions to follow? [link] (https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos) – jsonmullings May 12 '21 at 17:56
  • This may be discussed already but the fact that your permission denied error is referencing a path in `/usr/local/lib/ruby` tells me that your call to `gem` is not using the `gem` executable provided by `rbenv`, so you should investigate your installation of `rbenv` and check that it has been correctly installed. To confirm you should be able to run `which gem` and get a path that points to a location within your `rbenv` installation directory, typically `~/.rbenv/shims/gem`. – taylorthurlow May 12 '21 at 19:27
  • @taylorthurlow when I run `which gem` I get `/usr/local/opt/ruby/bin/gem` I have very little experience with this realm and have no idea how to solve this. – jsonmullings May 12 '21 at 19:43
  • Does this answer your question? [How do I remove Permission denied @ rb\_sysopen - Gem install error?](https://stackoverflow.com/questions/44770882/how-do-i-remove-permission-denied-rb-sysopen-gem-install-error) – Jared Beck May 12 '21 at 20:02
  • @jsonmullings You should read the documentation for `rbenv`: https://github.com/rbenv/rbenv#how-it-works – taylorthurlow May 12 '21 at 20:39

0 Answers0