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
Fix 1180: local cache broken #1568
Conversation
Thanks for your pull request and interest in making D better, @andre2007! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. |
Also a questions/proposal: should the dependencies which are retrieved with cache=local be stored in a sub folder "packages" of the dub package folder? At the moment they are stored directly in dub package folder. By storing them in a sub folder the developer has a better overview and it is more consistent with the user and system cache. |
{ | ||
"name": "test", | ||
"dependencies": { | ||
"local-cache-lib": "~master" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good idea because it could add unwanted overrides (in either direction) if the user uses this to load their submodules as dependency because it could conflict with a package on the dub registry. Also not specifying path is making this really hard to parse for existing tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is hard to answer here, because I do not know whether --cache=local is fully implemented and works as designed or a half implemented feature. There is no documentation.
Yes, as the depencenies(fetched with cache local) stored in the package folder, this could conflict with sub modules. My idea is to enhance the cache=local functionality and store the depencenies in a subfolder "packages".
But maybe there is a reason why cache=local works as it works. Is the idea that the developer adds the path by hand to dub json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think allowing the package folders directly relative to the project without specifying path is a good idea.
I understand your last answer as response to my proposal? |
Well the cache is not something supposed to be added or edited manually (for permanent solutions) which this PR would imply and allow people to do. Reasons are that for example if vibe would start to use this as way to depend on some local package then anyone could just create a malicious package on the dub registry with the same name as the now depended package, running some prebuild command messing with your local machine. Also the other way around if the local packages are higher in precedence it could happen that you add a subpackage with the same name as a dub package you would like to depend on (for example you make a opengl subpackage for your package) |
I need some hours to reason about. For the moment I am not sure what steps needs to be done.
|
I implemented option 3. Please see pr description for the benefits. Test is adapted. |
@WebFreak001 Could you have a second look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, the cache only makes sense on a global level, no?
@@ -804,7 +804,7 @@ class Dub { | |||
|
|||
NativePath placement; | |||
final switch (location) { | |||
case PlacementLocation.local: placement = m_rootPath; break; | |||
case PlacementLocation.local: placement = m_rootPath ~ ".dub/packages/"; break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use buildPath for Windows support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is working fine on windows, as placement is of type NativePath.
Should I still change coding to buildPath?
source/dub/packagemanager.d
Outdated
this(NativePath package_path, NativePath user_path, NativePath system_path, bool refresh_packages = true) | ||
{ | ||
m_repositories = [ | ||
Repository(package_path~ ".dub/packages/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is working fine on windows as Repository constructor also uses NativePath.
@@ -15,5 +15,4 @@ sleep 0.5 | |||
cd ${TMPDIR} && $DUB fetch --cache=local bloom & | |||
pid2=$! | |||
wait $pid1 | |||
wait $pid2 | |||
[ -d ${TMPDIR}/bloom* ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this nullifying the test? Why was this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, changed to [ -d ${TMPDIR}/.dub/packages/bloom* ]
The local cache makes most sense for me on CI servers like Jenkins. Also after the build, I need all of my project files and all dependencies source code files for further processing. For example I want to execute WhiteSource on them which is a tool for IP scanning. This is also quite easy with cache=local. |
I always hacked around this with |
Though I would love to hear a third option on this before merging, @s-ludwig or @MartinNowak maybe? |
Another reason the user would want to have those packages locally is for interaction with tools, such as IDE, or simply @andre2007 : Can you rebase on master ? |
@Geod24 it is rebased now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, LGTM
Comments have been addressed, packages are now stored in .dub/packages/
If you use --cache=local
e.g.
the dependencies are stored in the package folder but ignored by dub. That was the reason why for
the example the error message "Non-optional dependency vibe-d of vibetest not found in dependency tree!?." is raised.
This pull request propose to store the packages for --cache=local in folder
<dub-package-folder>/.dub/packages
instead of<dub-package-folder>/
This new location is also added the the package folders, Dub is aware of.
Benefits