1

I am using elasticsearch-ruby gem in my API application running on Ruby on Rails 6. In development env everything is running fine but for testing I wanted to create test cluster using elasticsearch-extensions gem. I am getting following error when I run rspec and trying to start server. I am using Ubuntu 18.04.

Starting 2 Elasticsearch nodes../usr/share/elasticsearch/bin/elasticsearch-env: line 81: /etc/default/elasticsearch: Permission denied
/usr/share/elasticsearch/bin/elasticsearch-env: line 81: /etc/default/elasticsearch: Permission denied
scs
  • 119
  • 7

2 Answers2

0

What Elasticsearch version?
How was Elasticsearch installed?
Output from ls -l /etc/default/elasticsearch?

This should fix your problem if the ownership settings are wrong:

sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch

Per https://discuss.elastic.co/t/permission-denied-starting-elasticsearch-7-0/179336

tamth
  • 154
  • 3
  • Output of above command is as follow. I can start server normally but when I run rspec and trying to run new cluster on new port 4250 then it gives above error. `-rw-rw---- 1 elasticsearch elasticsearch 1673 Oct 16 16:13 /etc/default/elasticsearch` – scs Dec 19 '20 at 08:41
  • Can you try exporting `DEBUG=true` to your environment and then re-running and posting the output here? It should print more information. – tamth Dec 19 '20 at 20:54
0

Set the environment variable TEST_CLUSTER_COMMAND like such:

TEST_CLUSTER_COMMAND=/usr/share/elasticsearch/bin/elasticsearch

(assuming this is the path in your case)

In my case this was happening because I configured TEST_CLUSTER_COMMAND to be /usr/share/elasticsearch, missing the /bin/elasticsearch

fabriciofreitag
  • 2,843
  • 22
  • 26