Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Postinstall script permission denied #300

Closed
drewjs opened this issue Jun 20, 2017 · 11 comments
Closed

Postinstall script permission denied #300

drewjs opened this issue Jun 20, 2017 · 11 comments
Assignees

Comments

@drewjs
Copy link

drewjs commented Jun 20, 2017

Trying to install the sdk on the latest originate/exosphere-base docker image. Any ideas for a fix or workaround?

  • node v6.7.0
  • npm v3.10.3

Dockerfile:

FROM originate/exosphere-base:latest

RUN apt-get update
RUN apt-get install -y apt-transport-https  \
    libtool pkg-config build-essential      \
    autoconf automake libzmq-dev
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn

RUN npm install -g exosphere-sdk
> npm i -g exosphere-sdk

...

npm info lifecycle exosphere-sdk@0.22.1~postinstall: exosphere-sdk@0.22.1

> exosphere-sdk@0.22.1 postinstall /usr/local/lib/node_modules/exosphere-sdk
> bin/yarn-install

installing subproject dependencies...
error An unexpected error occurred: "EACCES: permission denied, mkdir '/root/.config/yarn/global'".
child_process.js:526
    throw err;
    ^

Error: Command failed: yarn
error An unexpected error occurred: "EACCES: permission denied, mkdir '/root/.config/yarn/global'".

    at checkExecSyncError (child_process.js:483:13)
    at execSync (child_process.js:523:13)
    at setupProject (/usr/local/lib/node_modules/exosphere-sdk/bin/yarn-install:20:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/exosphere-sdk/bin/yarn-install:26:3)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
npm info lifecycle exosphere-sdk@0.22.1~postinstall: Failed to exec postinstall script
npm ERR! Linux 4.9.27-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-g" "exosphere-sdk"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
@kevgo
Copy link
Contributor

kevgo commented Jun 23, 2017

Which Linux version is this happening on? On your machine, or CircleCI?

@kevgo
Copy link
Contributor

kevgo commented Jun 23, 2017

Hey @mcharawi can you please reach out to @drewjs, investigate, and fix this issue? Please let me know if you want to pair up on this. Thanks!

@drewjs
Copy link
Author

drewjs commented Jun 23, 2017

This is for Docker running locally as a root user on the container. CircleCI has no issues with the build so I'm not sure how it's treating permissions differently.

@hugoesthere
Copy link
Contributor

Why are you trying to run exosphere-sdk in a Docker container?

Also, does anyone know what the originate/exosphere-base Dockerfile looks like (@trushton)? I've seen some similar EPERM issues using npm packages that were built FROM node (as opposed to FROM nodesource/node which we were using at one point). But that was during run time not install time so it could be an unrelated. Never found a solution to the EPERM issue either.

@drewjs
Copy link
Author

drewjs commented Jun 23, 2017

The container utilizes a number of SDK commands to test and run the application. exo run starts a number of locally running microservices along with a webserver (with exorelay) to send messages between the webserver and services.

You can view the repo here

@hugoesthere
Copy link
Contributor

Still not sure why you guys need to run exosphere-sdk inside a Docker container. Is this something leftover from the 0MQ days? Because now Exosphere runs every service itself inside a Docker container. Or are you running the whole app inside a Docker container and hitting that container in your tests?

Anyways, looks like it's a permissions issue. npm is run as root inside a Docker container, but install scripts aren't. You'll have to set the --unsafe-perm flag: dat-ecosystem/dat#466 (comment)

This worked for me:

#Dockerfile
FROM node

RUN npm i -g --unsafe-perm exosphere-sdk@0.22.1

@kevgo
Copy link
Contributor

kevgo commented Jun 23, 2017

@drewjs please try to run Exosphere outside of a Docker container. It uses Docker itself.

@drewjs
Copy link
Author

drewjs commented Jun 23, 2017

Yes, currently the entire application (excluding datastore) is running inside a single docker container. The application was previously using exosphere-sdk@0.9.0, but we recently updated to the latest version in order to fix our CircleCI tests. The old version of exosphere-sdk may have been involved with the decision to use a single container.

I will see what can be done to remove the exosphere-sdk requirement inside the container, but it may require some effort to update all the configuration. It may be helpful to know what is configured on the originate/exosphere-base:latest docker image as well.

@kevgo
Copy link
Contributor

kevgo commented Jun 23, 2017

Okay, that makes sense. Please don't run inside a Docker container anymore. Here is another Exosphere code base that runs outside of Docker: https://github.com/Originate/space-tweet. Please take it as a reference for how EaaS should look like moving forward.

What you need installed on your machine to run your application is:

  • Docker
  • Exosphere

@hugoesthere
Copy link
Contributor

hugoesthere commented Jun 23, 2017

Yes, I agree it would be helpful to know what's inside originate/exosphere-base:latest. My guess is that's some base node image and maybe Cucumber is installed or something. Like @kevgo said, all you really need is Docker and Node to run an Exosphere application.

@kevgo
Copy link
Contributor

kevgo commented Jul 6, 2017

This is resolved now that EaaS runs on the latest version of Exosphere

@kevgo kevgo closed this as completed Jul 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants