# Elastic Agent "chown" issues on Mac

**URL:** <https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337>\
**Category:** Elastic Agent\
**Tags:** fleet\
**Created:** [December 15, 2022, 6:06pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337 "2022-12-15T18:06:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kshort](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kshort](https://discuss.elastic.co/u/kshort)\
**Post date:** [December 15, 2022, 6:06pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/1 "2022-12-15T18:06:50Z")

</div>

I have an issue when adding the elastic-agent on a Mac. I am following the "Install Elastic Agent on your host" instructions provided for Mac by my agent policy. When starting URL enrollment I get the error:

"Error: failed to fix permissions: chown /Library/Elastic/Agent/data/elastic-agent-0e1a73/elastic-agent.app: operation not permitted"

The /Library/Elastic/Agent directory does not exist after the install fails. The /Library/Elastic directory is created, but the Agent sub-directory is not.

If I manually create the /Library/Elastic/Agent directory, copy of the contents of the tar.gz file into it, and then run ./elastic-agent enroll instead of install I can get the agent to start.

Happens for both x86\_64 and aarch64 systems (using the 8.5.3 version for x86\_64 and aarch64 downloads respectively). Any thoughts as to why this happens and how to fix it?

The instructions I am following are (url and token removed for post):

```auto
curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.5.3-darwin-x86_64.tar.gz
tar xzvf elastic-agent-8.5.3-darwin-x86_64.tar.gz
cd elastic-agent-8.5.3-darwin-x86_64
sudo ./elastic-agent install --url= --enrollment-token=

```

Thanks!

---

<div class="post-metadata">

**Author:** ![MichelLaterman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michellaterman/32/110221_2.png) [@MichelLaterman](https://discuss.elastic.co/u/MichelLaterman)\
**Post date:** [December 19, 2022, 7:25pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/2 "2022-12-19T19:25:46Z")

</div>

I think that if you manually create the `Agent` dir it wouldn't be associated with the correct user for elastic-agent to run as expected.

Can you delete the directory then post the output of the install command?

---

<div class="post-metadata">

**Author:** ![kshort](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kshort](https://discuss.elastic.co/u/kshort)\
**Post date:** [January 4, 2023, 4:32pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/3 "2023-01-04T16:32:29Z")

</div>

Sure thing. Here is the output of the install command.

```auto
Elastic Agent will be installed at /Library/Elastic/Agent and will run as a service. Do you want to continue? [Y/n]:

{"log.level":"info","@timestamp":"2023-01-04T11:22:14.650-0500","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":471},"message":"Starting enrollment to URL: (url removed)","ecs.version":"1.6.0"}

Error: failed to fix permissions: chown /Library/Elastic/Agent/data/elastic-agent-0e1a73/elastic-agent.app: operation not permitted

For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.5/fleet-troubleshooting.html

Error: enroll command failed with exit code: 1

For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.5/fleet-troubleshooting.html

```

---

<div class="post-metadata">

**Author:** ![MichelLaterman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michellaterman/32/110221_2.png) [@MichelLaterman](https://discuss.elastic.co/u/MichelLaterman)\
**Post date:** [January 4, 2023, 7:07pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/4 "2023-01-04T19:07:46Z")

</div>

Who owns `/Library/Elastic/Agent`?

---

<div class="post-metadata">

**Author:** ![kshort](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kshort](https://discuss.elastic.co/u/kshort)\
**Post date:** [January 4, 2023, 7:48pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/5 "2023-01-04T19:48:05Z")

</div>

That directory doesn't exist. It doesn't seem to get created with the install command after it fails.

`/Library/Elastic/` also doesn't exist.

---

<div class="post-metadata">

**Author:** ![ReneKalff](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@ReneKalff](https://discuss.elastic.co/u/ReneKalff)\
**Post date:** [January 5, 2023, 3:14pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/6 "2023-01-05T15:14:35Z")

</div>

Same issue here. Could it be that the .app is running at the time the chmod is performed? Installing the agent first without onboarding and then performing the enroll seems to work.  
sudo ./elastic-agent install -f  
sudo elastic-agent enroll --url= --enrollment-token=

---

<div class="post-metadata">

**Author:** ![ReneKalff](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@ReneKalff](https://discuss.elastic.co/u/ReneKalff)\
**Post date:** [January 17, 2023, 8:40am UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/7 "2023-01-17T08:40:35Z")

</div>

And another issue, the install fails is /usr/local/bin directory doens't exist. In our corporate environment some mac's do have that directory and some don't.

---

<div class="post-metadata">

**Author:** ![kshort](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kshort](https://discuss.elastic.co/u/kshort)\
**Post date:** [January 27, 2023, 4:33pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/8 "2023-01-27T16:33:24Z")

</div>

Yep this seemed to work, thank you! I haven't come across any macs where /usr/local/bin doesn't exist, but will keep an eye out for that as well.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 24, 2023, 4:34pm UTC](https://discuss.elastic.co/t/elastic-agent-chown-issues-on-mac/321337/9 "2023-02-24T16:34:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
