# MacOS Installation Gem::FilePermissionError

**URL:** https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607
**Category:** Self-hosting
**Created:** [June 22, 2020, 7:48pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607 "2020-06-22T19:48:24Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![taco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/taco/32/181150_2.png) [@taco](https://meta.discourse.org/u/taco)
#### Post date: [June 22, 2020, 7:48pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/1 "2020-06-22T19:48:24Z")

</div>

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

```plaintext
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.

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 22, 2020, 7:57pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/2 "2020-06-22T19:57:09Z")

</div>

Did you run through the script install of Discourse here?

> [@Install Discourse on macOS for development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772):
>
> warning This guide covers installation instructions for a macOS development environment, for production guides see: [Install Discourse in production with the official supported instructions](https://meta.discourse.org/t/how-to-install-discourse-in-production/142537) So you want to set up Discourse on macOS to hack on and develop with? We’ll assume that you don’t have Ruby/Rails/Postgres/Redis installed on your Mac. Let’s begin rocket ! Install Discourse Dependencies You will need the following packages on your system: [Git](http://git-scm.com/)[rbenv](https://github.com/sstephenson/rbenv) or [asdf](https://asdf-vm.com/guide/getting-started.html)[ruby-build](https://github.com/sstephenson/ruby-build)[Ruby](https://www.ruby-lang.org/) (latest s…

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.

---

<div class="post-metadata">

### Author: ![taco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/taco/32/181150_2.png) [@taco](https://meta.discourse.org/u/taco)
#### Post date: [June 22, 2020, 7:58pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/3 "2020-06-22T19:58:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 22, 2020, 8:01pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/4 "2020-06-22T20:01:31Z")

</div>

Can you paste the output of `which rbenv`?

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

---

<div class="post-metadata">

### Author: ![taco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/taco/32/181150_2.png) [@taco](https://meta.discourse.org/u/taco)
#### Post date: [June 22, 2020, 8:05pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/5 "2020-06-22T20:05:15Z")

</div>

> [@justin](#):
>
> Can you paste the output of `which rbenv` ?

/usr/local/bin/rbenv

> [@justin](#):
>
> And do you have a custom `.bashrc` or `.zshrc` ?

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

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 22, 2020, 8:08pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/6 "2020-06-22T20:08:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![taco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/taco/32/181150_2.png) [@taco](https://meta.discourse.org/u/taco)
#### Post date: [June 22, 2020, 8:12pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/9 "2020-06-22T20:12:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 22, 2020, 8:17pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/10 "2020-06-22T20:17:43Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 22, 2020, 9:25pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/11 "2020-06-22T21:25:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 22, 2020, 9:26pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/12 "2020-06-22T21:26:35Z")

</div>

I believe that was for the theme cli.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 22, 2020, 9:27pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/13 "2020-06-22T21:27:02Z")

</div>

Is there some way to add an equivalent check here?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 22, 2020, 9:29pm UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/14 "2020-06-22T21:29:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![rudzainy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rudzainy/32/226573_2.png) [@rudzainy](https://meta.discourse.org/u/rudzainy)
#### Post date: [June 6, 2022, 1:53am UTC](https://meta.discourse.org/t/macos-installation-gem-filepermissionerror/155607/15 "2022-06-06T01:53:00Z")

</div>

1. I encountered the same error as the OP.

2. Read this:

> [@justin](#):
>
> If not, add them in your shell’s configuration file `.bashrc` or .`zshrc`.

1. Thought that it’s not actually a file permission error, rather the installer was looking at the wrong place.

2. I knew that restarting the terminal would reload my .zshrc file, so I closed and opened the terminal.

3. I run the installation script again and I didn’t encounter this error anymore.

Could this issue be resolved with a terminal refresh strategically placed during the install process? 🤔
