MacOS Installation Gem::FilePermissionError

When installing Discourse (for development) on my Mac I get this error:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

How can I resolve this?
Thanks.

1 me gusta

Did you run through the script install of Discourse here?

Are you running macOS Catalina? If that’s the case, it sounds like you’re running into Discourse trying to use the system version of ruby. You’ll want to use something like rbenv to set your ruby version to avoid this.

1 me gusta

I am running MacOS Catalina. And I did run that script but it failed half way through because it was installed I think.

Can you paste the output of which rbenv?

And do you have a custom .bashrc or .zshrc?

1 me gusta

/usr/local/bin/rbenv

Not really sure. I don’t think so but maybe.

Can you cd into your discourse directory and share the output of which ruby?

1 me gusta

Oops, didn’t notice. I did it and got /usr/bin/ruby

Okay, so you’re using the system ruby for Discourse which is why you’re getting that issue.

Check the PATH variable by typing in echo $PATH. You should see /Users/<your username>/.rbenv/bin and /Users/<your username>/.rbenv/shims listed in there.

If not, add them in your shell’s configuration file .bashrc or .zshrc. For ZSH you can add it like this: export PATH=/path/number/1:/path/number/2:$PATH

If you do see them, check to see what order they’re in. If they are later in the chain, they’re probably not getting loaded before the system ruby meaning the system ruby is being used for Discourse. You can use the same approach above for moving the paths further up the chain.

3 Me gusta

I thought @david added a Ruby version check to our dev environment stuff? :thinking:

I believe that was for the theme cli.

2 Me gusta

Is there some way to add an equivalent check here?

I think we already check in Discourse for ruby version compatibility — the issue here is our Discourse bundle can’t write gems for the system level version of ruby bundled with macOS. I could be wrong on the specific details but I think it has to do with a change Apple made with macOS Catalina. I ran into this same issue myself and it took a good deal of troubleshooting to figure out.

1 me gusta
  1. Me encontré con el mismo error que el OP.

  2. Lee esto:

  1. Pensé que en realidad no era un error de permisos de archivo, sino que el instalador estaba mirando en el lugar equivocado.

  2. Sabía que reiniciar el terminal recargaría mi archivo .zshrc, así que cerré y abrí el terminal.

  3. Volví a ejecutar el script de instalación y ya no me encontré con este error.

¿Podría resolverse este problema con una actualización del terminal estratégicamente colocada durante el proceso de instalación? :thinking: