Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bower permission issue at openshift #29

Closed
erikwoo opened this issue Oct 14, 2013 · 13 comments
Closed

bower permission issue at openshift #29

erikwoo opened this issue Oct 14, 2013 · 13 comments

Comments

@erikwoo
Copy link

erikwoo commented Oct 14, 2013

hi there.
I run mimosa on openshift.
when requiring mimosa bower. there's a permission issue when bower/node_modules/mkdirp trying to access ~/.local

node -e 'require("path/to/mimsoa-bower")'

---log---
Error: EACCES, permission denied '/var/lib/openshift/5258ab064**cf602000003/.local'
at Object.fs.mkdirSync (fs.js:642:18)
at sync (/var/lib/openshift/5258ab064382ecf602000003/app-root/runtime/repo/node_modules/mimosa-bower/node_modules/bower/node_modules/mkdirp/index.js:55:12)
at sync (/var/lib/openshift/5258ab064382ecf602000003/app-root/runtime/repo/node_modules/mimosa-bower/node_modules/bower/node_modules/mkdirp/index.js:61:24)
at sync (/var/lib/openshift/5258ab064382ecf602000003/app-root/runtime/repo/node_modules/mimosa-bower/node_modules/bower/node_modules/mkdirp/index.js:61:24)
at Function.sync (/var/lib/openshift/5258ab064382ecf602000003/app-root/runtime/repo/node_modules/mimosa-bower/node_modules/bower/node_modules/mkdirp/index.js:61:24)
at Object. (/var/lib/openshift/5258ab064382ecf602000003/app-root/runtime/repo/node_modules/mimosa-bower/node_modules/bower/lib/core/resolvers/GitResolver.js:28:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

@erikwoo erikwoo closed this as completed Oct 14, 2013
@sontl
Copy link

sontl commented Nov 26, 2013

can I know how did you solve this issue?

@erikwoo
Copy link
Author

erikwoo commented Dec 29, 2013

set HOME=/var/lib/openshift/5258ab064382ecf602000003/app-root/runtime/repo/ in a hook or make it a devDependency.

@saxicek
Copy link

saxicek commented Mar 4, 2014

The best solution I found is to change HOME just for the Bower call:

  "scripts": {
    "build-js": "HOME=$HOME/app-root/runtime bower install && r.js -o build-config.js",
  },

@kibotu
Copy link

kibotu commented Aug 14, 2014

what is r.js and build-config.js?
btw for everyone else who struggled: http://tamas.io/deploying-a-node-jssocket-io-app-to-openshift/
basically

good luck~

@saxicek
Copy link

saxicek commented Aug 14, 2014

r.js is build script for Require.js - it is not relevant for this issue.

@JasonGhent
Copy link

This solution partially worked for me, but resulted in the creation of a /Users/me/app-root/runtime/repo directory when run locally. To get around this I tried an action_hook, but that will not work for reasons described by OpenShift staff here.

Instead, I moved the bower install into my application. It adds overhead to the application start time, but otherwise works well.

// Bower hack for OpenShift
var bower = 'HOME=$HOME/app-root/runtime ./node_modules/.bin/bower install';
bower = process.env.OPENSHIFT_REPO_DIR ? bower : bower.substr(28);
bower = require('child_process').exec(bower);
bower.on('exit', app.run.bind(app));

@DLDante
Copy link

DLDante commented Nov 1, 2014

well, for each time you need to use bower install, you can use export HOME=$HOME/app-root/runtime/repo in the RHC tool, and then into the folder "./app-root/repo" you can use the bower install, if bower command is not available, go to folder "./nodejs" and do npm install bower.

Then, in order with RHC tool:

  • 1 - rhc ssh proyectname
  • 2 - cd nodejs
  • 3 - npm install bower
  • 4 - cd ..
  • 5 - export HOME=$HOME/app-root/runtime/repo
  • 6 - cd app-root/repo
  • 7 - bower install

done! good luck with your projects

@quantuminformation
Copy link

@DLDante is this still the best most generic way to get bower install to work?

@saxicek
Copy link

saxicek commented Dec 29, 2014

@quantuminformation basically yes but I would avoid doing those steps manually. Remember that shell is last instance in OpenShift and you are perfectly able to do everything from package.json. See mine for working example - https://github.com/saxicek/odpad-praha8.cz/blob/master/package.json#L51.

@PixelWaffles
Copy link

@JasonGhent I'm not sure if this is still relevant to you after so many months, but I encountered this problem and solved it by adding conditionals around the execution code:

"postinstall": "if [ -d \"$OPENSHIFT_REPO_DIR\" ]; then (export HOME=\"$OPENSHIFT_REPO_DIR\"/..; bower install) else (bower install) fi",

It's a tad dirty (mostly due to the love hate relationship between .json and newlines), but it should be a much more elegant solution than including build code within the app proper.

cainrus pushed a commit to cainrus/repotracktor that referenced this issue Jun 6, 2015
@deathmood
Copy link

Solved it with this build action hook:

if [ ! -d $OPENSHIFT_NODEJS_DIR/node_modules/bower ]
then
    cd $OPENSHIFT_NODEJS_DIR
    npm install bower
fi

cd $OPENSHIFT_HOMEDIR/app-root/repo
HOME=$OPENSHIFT_REPO_DIR bower install
cd $OPENSHIFT_HOMEDIR

@rdjs
Copy link

rdjs commented Sep 7, 2015

The fix referencing @ginsederp comment worked for me:

cainrus/repotracktor@f3c856d

in package.json:

"postinstall": "if [ -d \"$OPENSHIFT_REPO_DIR\" ]; then (export HOME=\"$OPENSHIFT_REPO_DIR\"/..; $(npm bin)/bower install) else ($(npm bin)/bower install) fi && npm run setup"

@AndyOGo
Copy link

AndyOGo commented Nov 2, 2017

How about Openshift version 3?
The environment variable $OPENSHIFT_REPO_DIR is gone there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests