cli: The app upload is invalid: Symlink(s) point outside of root folder

Command

I have a very simple node app

package.json

{
  "name": "test-link",
  "version": "1.0.0",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.16.2"
  }
}

server.js

let express = require('express');

let app = express();
app.use((req, res) => {
  res.send('OK');
});
app.listen(process.env.PORT);
npm install
cf push test-link

What occurred

Push failed with this error

Waiting for API to complete processing files...
Job (240257ea-c821-4026-bffa-041eb4492f3a) failed: The app upload is invalid: Symlink(s) point outside of root folder
FAILED

What you expected to occur

I expected push to succeed. There is a single symlink and it points inside the app folder.

$ find . -type l
./node_modules/.bin/mime
$ ll ./node_modules/.bin/mime
lrwxr-xr-x  1 i031257  GLOBAL\Domain Users  14 Jan 10 10:20 ./node_modules/.bin/mime -> ../mime/cli.js

CLI Version

$ cf -v
cf version 6.34.0+f53d03a5e.2018-01-09

CC API Endpoint Version

$ cf api
api endpoint:   https://...
api version:    2.99.0

Platform & Shell Details

Mac OS 10.13.2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (2 by maintainers)

Commits related to this issue

Most upvoted comments

The problem here is that - depending on your setup - it might not be possible to just delete node_modules. When having dependencies that are only available to your host running the build/deployment, but not to the CF environment, this workaround doesn’t help.

I hope this will be fixed soon. In the meantime, if you need to push with modules, this helps:

npm install --no-bin-links

You need to add “.cfignore” file to ignore folder “node_modules” (if Node.js) or any orher folder that has potential Symlinks pointing outside.

Looks like a known issue that many are going to hit as they follow the message PRO TIP: It is recommended to vendor the application's Node.js dependencies when pushing a node.js app.

http://docs.cloudfoundry.org/buildpacks/node/index.html#vendoring

For me this was caused by node_modules/.bin - just adding that to my .cfignore resolved things.

Try “before_build” in Travis CI with “rm -R ./node_modules”