wanderors
wanderors

Reputation: 2292

Device Farm appium nodejs - Not able to do sudo

I am using device farm for my appium nodejs project. So for capturing a screenshot of report, we are using a wkhtmltoimage. For that I need to install the module using command sudo apt-get wkhtmltopdf

But sudo is not working in devicefarm. I am getting error - sudo: no tty present and no askpass program specified

When I try without sudo I get error

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

I have set the policy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "devicefarm:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

Am I missing something because of which I cant run sudo ? Please help

Upvotes: 0

Views: 313

Answers (1)

Renan Machado
Renan Machado

Reputation: 21

The solution for me was to run the installation with extra flags

npm install -g --unsafe-perm=true --allow-root

Where --unsafe-perm=true will suppress user/group switching and --allow-root will allow it to be executed as the root user. If unsafe-perm is set to false the installation will fail when installed by any other user other than root.

You can read more on this here https://geedew.com/What-does-unsafe-perm-in-npm-actually-do/

Upvotes: 2

Related Questions