cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open dotchev opened this issue 8 years ago • 20 comments

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

dotchev avatar Jan 10 '18 08:01 dotchev

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/154202779

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar Jan 10 '18 08:01 cf-gitbot

Maybe CloudFoundry should ignore uploading all symlinks pointing "outside folder"?

MichaelOrtho avatar Jan 19 '18 18:01 MichaelOrtho

My deployment can not work, because of this "symlink" issue.

zhyinjun avatar Jan 22 '18 01:01 zhyinjun

I'm also unable to deploy due to this issue.

rkomiyama avatar Jan 22 '18 01:01 rkomiyama

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

MichaelOrtho avatar Jan 22 '18 13:01 MichaelOrtho

@MichaelOrtho I've tried that, but my Travis build fails when it tries to load something from devDependencies in package.json.

rkomiyama avatar Jan 22 '18 13:01 rkomiyama

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

MichaelOrtho avatar Jan 22 '18 13:01 MichaelOrtho

@MichaelOrtho Did you mean "before_deploy" instead of "before_build"?

rkomiyama avatar Jan 22 '18 14:01 rkomiyama

Sorry... Of course. Just add:

...
before_deploy:
- rm -R ./node_modules
...

Check this Travis deployment issue connected to CloudFoundry/Bluemix https://github.com/travis-ci/dpl/issues/734

MichaelOrtho avatar Jan 22 '18 14:01 MichaelOrtho

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

clncln1 avatar Jan 22 '18 16:01 clncln1

You can try to use bluemix custom script, but I would assume bluemix will be updated to include same "Simlinks" push so you will have same issue. This is using bluemix client (last build). Maybe we can pick previous version of cf before v6.34.

https://github.com/travis-ci/dpl/issues/734#issuecomment-357978383

MichaelOrtho avatar Jan 22 '18 16:01 MichaelOrtho

Had the same issues just now. Deleted my node_modules folder, did cf push and it worked.

francisgauthier93 avatar Jan 22 '18 22:01 francisgauthier93

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

dcolebatch avatar Jan 28 '18 01:01 dcolebatch

Just came here to say that I experienced this issue out of the blue while trying to do an emergency re-deployment of a python web app using the python buildpack on PWS (a public instance of cloud foundry). Not a pleasant surprise!

If you do experience this error while deploying a python application with the python buildpack, the likely culprit is that you didn't add your virtualenvs folder to the .cfignore file. For instance, if your application's virtualenv folder is called env at the project root, you would add a line with env in it to the .cfignore file. That worked in my case and after adding it, I was able to do a successful deploy of my application.

I would have really appreciated a little bit more verbose feedback from the CLI to point me at the exact issue. For instance, the path to the offending symlink in question would have been really helpful. Thanks for taking the time to read the feedback, hope it was helpful.

wileykestner avatar Feb 18 '18 21:02 wileykestner

We're still seeing this issue and are fixing our version of CF CLI to before 6.34 so that we're still able to deploy.

berlin-ab avatar Feb 24 '18 02:02 berlin-ab

@dotchev @xi4oc4i @rkomiyama @clncln1 @francisgauthier93 @dcolebatch @wileykestner @berlin-ab Looks like our colleagues on the CC team delivered a related fix. Does this solve your problem? https://github.com/cloudfoundry/cloud_controller_ng/issues/1057

jbpivotal avatar Feb 27 '18 00:02 jbpivotal

Closing as wontfix for CLI. Fixed on Cloud Controller as mentioned in earlier comment.

jbpivotal avatar Mar 07 '18 22:03 jbpivotal

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

dnfield avatar Apr 18 '18 19:04 dnfield

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

Ended up in this thread because a Python app failed with the error

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

Deleting virtualenv dir resolved.

scrypt-kitty avatar Sep 14 '18 18:09 scrypt-kitty

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

This worked for me .

gangulymanish avatar Feb 14 '19 17:02 gangulymanish