cf push does not include the symlinked module in node_modules...
I've created some custom node modules, they are linked into the main node app via "npm link ../module1".. Then the node_modules of main node app includes following structure...
node_modules .... request module1 <- symlink module2 <- symlink module3 <- symlink ejs ....
Command
cf push demoapp
CLI Version
6.20.0+25b1961-2016-06-29
Stack Trace
➜ demoapp git:(master) ✗ cf push demoapp Using manifest file /git/demoapp/manifest.yml
.....
Uploading demoapp...
Uploading app files from: /git/demoapp
Uploading 14.1M, 4919 files
Done uploading
OK
.....
Server log
2016-07-27T11:22:59.470+0800[App/0]ERRmodule.js:328 2016-07-27T11:22:59.470+0800[App/0]ERRError: Cannot find module 'module1' 2016-07-27T11:22:59.470+0800[App/0]ERR throw err; 2016-07-27T11:22:59.470+0800[App/0]ERR at Module.require (module.js:354:17) 2016-07-27T11:22:59.470+0800[App/0]ERR at Function.Module._resolveFilename (module.js:326:15)
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/127146091
The labels on this github issue will be updated when the story is started.
Hi @xi4oc4i
I believe you are requesting what we looked at doing in this story, but had to drop because we didn't know how to do it in Golang. Unless anyone has any suggestions on how to technically implement this, we won't be able to support it.
Regards, Dies Koper CF CLI PM
Closing, as we don't believe it's possible in Golang.
Hi folks!
We received a report on buildpacks which shows this issue is still affecting folks.
We think that it would be possible to include symlinks in zipfiles sent from CLI, using Golang std lib. Our belief is founded on the fact that there appears to be testing for this capability.
However, exploration on our part showed that even if we use -p to push a zipfile constructed using zip -y (a flag telling zip to include symlinks) don't work. So it appears there will need to be additional changes made in the staging logic.
We're unsure where, but a hunch is that cloud controller and/or Diego would be involved. @dieucao, @ematpl any idea of who we should pull in for an opinion?
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/132669013
The labels on this github issue will be updated when the story is started.
This may be worth reading: https://github.com/golang/go/issues/3720
@jchesterpivotal here are a few places where I think CF does zip processing that could mangle symlinks:
- CLI uploading zip contents to CC (I think it still unpackages zip files, does resource matching, then pushes the unmatched files as a new zip file),
- CC re-assembling the upload + resource-matched files into a new zip file to store in its app-package blobstore,
- Diego downloading the app-package zip file from CC's blobstore and transforming it into a tar stream to stream into the staging task container.
Might be illuminating to write a Diego Task that downloads a known-good zip file containing a symlink into a Garden container. Relatively easy to do with the BBS client, or you could wait for https://www.pivotaltracker.com/story/show/129376223.
cc @SocalNick
@ematpl @SocalNick
It would probably be very illuminating to write a Diego task, but we don't feel like we have the current expertise needed to do it efficiently. For diagnostic purposes we feel like one of the implementing teams might be better positioned to try that approach.
(this is all bureaucratese for "help!")
I've asked @XenoPhex to take a look in https://www.pivotaltracker.com/story/show/79898768
We need this feature too.
For security reasons we don't want to run npm for our node.js apps during staging. This may download untrusted code from the internet.
But this breaks npm bin commands, which are essentially symlinks stored under node_modules/.bin directory. Currently in the node.js buildpack these symlinks are recreated by npm rebuild command.
If golang does not support reading symlinks from a zip file, another option is to execute unzip command and it will restore correctly the symlinks.
Additional use cases for symlinks are mentioned in #108.
This has been resolved in v2-push of cf CLI 6.33.1.
This is now resolved in push as well, in cf CLI 6.34.0.
Regards, Dies Koper CF CLI PM
I still have problem with npm linked module not been upload to the cloud foundary.
@shaopengz What version of cf CLI are you using?
@jbpivotal cf.exe version 6.35.2+88a03e995.2018-03-15 have tried almost every version since 6.20.
still happens .
- cf version 6.36.1+e3799ad7e.2018-04-04
- macOS High Sierra 10.13.4 (17E199)
- api version: 2.94.0
we use
npm install --no-bin-links
to workaround