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

Serving static content from sys link directory is not working #20

Open
amrelhagary opened this issue Nov 24, 2017 · 9 comments
Open

Serving static content from sys link directory is not working #20

amrelhagary opened this issue Nov 24, 2017 · 9 comments

Comments

@amrelhagary
Copy link

I followed the instruction and I get a sys link folder bower_components linked to @bower_components in npm and when I refresh the index page it gives me 404.

@sheerun
Copy link
Owner

sheerun commented Nov 25, 2017

what do you mean by sys link? are you on windows? can you browse this folder using file explorer?

@amrelhagary
Copy link
Author

I am on Mac and I can browse the files, I am not sure what is the problem if I replaced the sys linked folder with actual bower_components it works. I am using docker on mac os.

@sheerun
Copy link
Owner

sheerun commented Nov 25, 2017

Do you mean symlinked? Could you prepare github repository to reproduce this issue?

@amrelhagary
Copy link
Author

I think the problem with docker.

@hsalokor
Copy link

hsalokor commented Nov 29, 2017

I just encountered the same issue. The root cause appears to be that yarn install creates absolute symlink, and this causes issues if the file system (or directory) is cloned via some form of sandboxing (openshift or docker?).

I fixed this by changing the postinstall hook to generate relative links.

node -e \"try { require('fs').symlinkSync('../node_modules/@bower_components', 'public/libs', 'junction') } catch (e) { }\"

This is a bit of a corner case though, but it might be sensible by default to generate relative symlinks?

@sheerun
Copy link
Owner

sheerun commented Nov 29, 2017

interesting

@hsalokor @GabLeRoux @samypr100 do relative symlinks work with windows junctions?

@hsalokor
Copy link

hsalokor commented Nov 29, 2017

I have no access right now to a Windows machine in order to test, but Node.js fs-module documentation seems to suggest that the above code would work, but would create absolute junction.

Note that Windows junction points require the destination path to be absolute. When using 'junction', the target argument will automatically be normalized to absolute path.

It probably needs some testing in real Windows environment - I think it would be acceptable to create relative links on OS X and Linux, and fall back to absolute paths on Windows.

@GabLeRoux
Copy link

I've created this repository to give this issue a try:
https://github.com/GabLeRoux/bower-away-test.git

In an administrator shell on Windows 10, I did this:

PS C:\Users\IEUser\Desktop> git clone https://github.com/GabLeRoux/bower-away-test.git
Cloning into 'bower-away-test'...
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 17 (delta 5), reused 17 (delta 5), pack-reused 0
Unpacking objects: 100% (17/17), done.
PS C:\Users\IEUser\Desktop> cd .\bower-away-test\
PS C:\Users\IEUser\Desktop\bower-away-test> dir


    Directory: C:\Users\IEUser\Desktop\bower-away-test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       11/29/2017   7:53 AM                public
-a----       11/29/2017   7:53 AM             38 .bowerrc
-a----       11/29/2017   7:53 AM             27 .gitignore
-a----       11/29/2017   7:53 AM            380 bower.json
-a----       11/29/2017   7:53 AM            537 package.json
-a----       11/29/2017   7:53 AM            291 yarn.lock


PS C:\Users\IEUser\Desktop\bower-away-test> yarn install
yarn install v1.3.2
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
$ node -e "try { require('fs').symlinkSync(require('path').resolve('node_modules/@bower_components'), 'public/libs', 'junction') } catch (e) { }"
Done in 5.26s.
PS C:\Users\IEUser\Desktop\bower-away-test> dir


    Directory: C:\Users\IEUser\Desktop\bower-away-test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       11/29/2017   7:53 AM                node_modules
d-----       11/29/2017   7:53 AM                public
-a----       11/29/2017   7:53 AM             38 .bowerrc
-a----       11/29/2017   7:53 AM             27 .gitignore
-a----       11/29/2017   7:53 AM            380 bower.json
-a----       11/29/2017   7:53 AM            537 package.json
-a----       11/29/2017   7:53 AM            291 yarn.lock


PS C:\Users\IEUser\Desktop\bower-away-test> dir .\public\libs\


    Directory: C:\Users\IEUser\Desktop\bower-away-test\public\libs


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       11/29/2017   7:53 AM                font-awesome

It worked well as expected, I used

bower-away --version
1.1.2

I will try with this when I get some more time.

-"postinstall": "node -e \"try { require('fs').symlinkSync(require('path').resolve('node_modules/@bower_components'), 'public/libs', 'junction') } catch (e) { }\""
+"postinstall": "node -e \"try { require('fs').symlinkSync('../node_modules/@bower_components', 'public/libs', 'junction') } catch (e) { }\""

@GabLeRoux
Copy link

Hint: I'm using a windows vm from Microsoft modern.ie's vms. This way, everybody can test on windows, but it takes a few minutes to setup. 👍

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

4 participants