-
Notifications
You must be signed in to change notification settings - Fork 710
Make add-source packages have priority over other packages #1197
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
Comments
Thanks for the feedback, I'll look into this. |
Actually, this problem exists even when hackage isn't involved. If I do |
Are you using |
I'm using sandbox-install. I figured that would be more appropriate given what I already know about the non-sandbox install/build distinction. |
Can you provide me with step-by-step instructions for how to reproduce your problem? |
|
@mightybyte Thanks! |
A simple solution is to just unregister the already-existing version. See also #1275. |
I completely agree, but there is no facility for unregistering packages in a sandbox. |
@mightybyte I was talking about internal implementation. To do this manually you can use the |
Oh, excellent. I hadn't seen that. |
I'm not sure if we can solve this completely automatically. I suggest that we make
|
Can we forcefully reinstall add-source dependencies if they have changed, overwriting whatever version was in the sandbox before? |
In What we can do, perhaps, is make |
I think fixing this issue is important. We want sandboxes to behave as-if you deleted the whole package DB and started over from scratch. Now, we don't want to actually do that, as it would be way to slow, so we'll have to come up with a solution. Possible that will include making the dep solver smarter i.e. but letting it know that certain versions have priority over others or that a certain constraint can only be fulfilled by an in-place version of a package. @kosmikus any ideas? |
I can implement my timestamp idea so that we can experiment with it. Basically, this will be equivalent to the following:
|
Now, this won't work for snapshots, but I think |
Lets not discard the "proper" solution (i.e. add a "unpacked"/"local" constraint to the solver, just like we have an "installed" constraint today) too quickly. Lets see how difficult it would be to implement first. |
We can start with a simple solution and then maybe implement a proper one. |
WIP. Implemented by touching the .cabal file of the newly-added add-source dep in 'doAddSource'. This triggers it to be reinstalled on the next 'cabal build'. Fixes haskell#1197.
One problem with the "proper" solution is that the timestamp check will prevent Doing reinstall in I think that touching the .cabal file in |
OK. Lets try to get something working in the mean time. We need to ship this thing! |
@dcoutts tells me that we can already express a preference for local packages. That's what e.g. |
I'm pretty sure we already have all the control we need in terms of constraints etc. Look at how we translate the PackageSpecifier into constraints for the solver. For a NamedPackage kind (e.g. cabal install foo) we allow any of installed or available src. For a SpecificSourcePackage kind (e.g. cabal install ./foo/foo.cabal) we add constraints so that it can only pick that specific src package, and not installed instances and not other available src packages of that name. See
As you can see, for the You can also see that for |
Yes, when we know that some add-source deps should be reinstalled then reinstalling them works absolutely fine. The problem is that the timestamp check prevents us from attempting to reinstall them. I'm currently thinking of the following solution:
This solution should also work in the presence of multiple package DBs inside the same sandbox (since timestamps are per-compiler). |
Fixes haskell#1197. This patch is a bit large because it includes several related changes: 1) Remove 'installUseSandbox' from 'InstallFlags' and pass 'useSandbox' as an additional argument instead. 2) Instead of calling 'reinstallAddSourceDeps' from 'installAction', always pass 'SandboxPackageInfo' to 'install'. 3) Set the timestamps of newly-added add-source deps to 0 in the timestamp file. 4) Move the timestamp file update to 'postInstallActions' from 'withModifiedDeps'. This way, the timestamps are updated even when the user runs 'install --only-dependencies' or 'install some-add-source-dep-package-id'.
Fixes haskell#1197. This patch is a bit large because it includes several related changes: 1) Remove 'installUseSandbox' from 'InstallFlags' and pass 'useSandbox' as an additional argument instead. 2) Instead of calling 'reinstallAddSourceDeps' from 'installAction', always pass 'SandboxPackageInfo' to 'install'. 3) Set the timestamps of newly-added add-source deps to 0 in the timestamp file. 4) Move the timestamp file update to 'postInstallActions' from 'withModifiedDeps'. This way, the timestamps are updated even when the user runs 'install --only-dependencies' or 'install some-add-source-dep-package-id'.
Fixes haskell#1197. This patch is a bit large because it includes several related changes: 1) Remove 'installUseSandbox' from 'InstallFlags' and pass 'useSandbox' as an additional argument instead. 2) Instead of calling 'reinstallAddSourceDeps' from 'installAction', always pass 'SandboxPackageInfo' to 'install'. 3) Set the timestamps of newly-added add-source deps to 0 in the timestamp file. 4) Move the timestamp file update to 'postInstallActions' from 'withModifiedDeps'. This way, the timestamps are updated even when the user runs 'install --only-dependencies' or 'install some-add-source-dep-package-id'.
Fixes haskell#1197. This patch is a bit large because it includes several related changes: 1) Remove 'installUseSandbox' from 'InstallFlags' and pass 'useSandbox' as an additional argument instead. 2) Instead of calling 'reinstallAddSourceDeps' from 'installAction', always pass 'SandboxPackageInfo' to 'install'. 3) Set the timestamps of newly-added add-source deps to 0 in the timestamp file. 4) Move the timestamp file update to 'postInstallActions' from 'withModifiedDeps'. This way, the timestamps are updated even when the user runs 'install --only-dependencies' or 'install some-add-source-dep-package-id'.
I described the following scenario in issue #1195.
I installed my package foo and it retrieved a dependency bar from hackage. Then I discovered that I in fact needed my locally modified version of bar. So I do
cabal sandbox-add-source ../bar
. But that doesn't do anything since it already has the version from hackage which satisfies the dependencies.It seems like the version added with add-source should take priority here.
The text was updated successfully, but these errors were encountered: