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

upgrade global packages #1899

Closed
legrostdg opened this issue Mar 10, 2016 · 9 comments
Closed

upgrade global packages #1899

legrostdg opened this issue Mar 10, 2016 · 9 comments

Comments

@legrostdg
Copy link

There should be a way to upgrade globally installed packages (other than running "stack install mypackage" for each package).

@mgsloan
Copy link
Contributor

mgsloan commented Mar 11, 2016

I don't understand what you want that stack install mypackage does not provide.

Note that you can do stack install mypackage-1.0 to specify a specific version.

Feel free to reopen with more explanation. If this is about the global package DB, we want to avoid mutating that as it's shared amongst all uses of the compiler.

@mgsloan mgsloan closed this as completed Mar 11, 2016
@legrostdg
Copy link
Author

I mean something like "npm upgrade -g": upgrade all the global packages, without having to do "stack install package1", "stack install package2", etc. to upgrade everything

@mgsloan
Copy link
Contributor

mgsloan commented Mar 11, 2016

Ah, I see! Yes, others have wanted this as well - see the discussion here for why stack isn't really intended for this usecase, and how to use it for this.

I've opened an issue with a potential way to streamline this usecase - #1904 . Shouldn't be very hard, but I think some other things should happen first. Essentially the only convenience this grants is that the stack.yaml can now keep track of which hackage packages to install when you do stack install. Without the change in the ticket, you'll need to list which packages to install on the commandline. However, automating that is as easy as writing a little script:

#!/bin/sh
stack install package1 package2

If you are fine with skipping out on having the resolver determine the package version (such that specifying lens will use the right version, no need to figure out the version), then you could also already use hackage tarball locations in your packages list or git repos in your packages list.

@flip111
Copy link
Contributor

flip111 commented Dec 15, 2017

Is there any way to get a list of packages that get loaded when you are not in a project (but in global project instead)? Is it then from there possible to remove all dependencies from that list? That way you only get the packages of which you would need to type stack install package to update them.

@mgsloan
Copy link
Contributor

mgsloan commented Dec 15, 2017

@flip111 Not sure I follow. The global project works exactly like a normal project, except that by default it has no local packages.

It sounds like what y'all want here is #115 - having commands that automatically modify a project configuration. We could do this now, however, there's no good way to do it that preserves existing layout and comments

@flip111
Copy link
Contributor

flip111 commented Dec 15, 2017

@mgsloan in the other discussion you say

There is no special tracking of which packages you've installed.

However when i run stack exec ghci i can import packages that at some point in time where installed with stack install package. But also dependencies of those package would have been installed.

For example, i stack install a which depends on b and n and i stack install x which depends on y and n. Now when i start stack exec ghci i can import packages a, b, n, x and y right?

Can i get this list a, b, n, x, y somehow? Can i then backwards figure out that only a and x where "top-level" packages (or whatever is an appropriate name here) and the rest are dependencies? If i get back a and x i can then run stack install a x to upgrade my global project.

It's just an idea .. not sure if this will work ..

@mgsloan
Copy link
Contributor

mgsloan commented Dec 15, 2017

True, stack exec ghci does let you access packages that you've installed. This is one thing that's rather nice about stack's approach to package DBs, which I believe that the new-build nix style cannot support.

stack exec -- ghc-pkg list may give you what you're looking for, as far as getting the full list. However, stack does not write down what has been asked for explicitly via install.

Also, note that for most packages build is the exact same as install. The only difference is if the package has an executable, install copies it into ~/.local/bin.

@mgsloan
Copy link
Contributor

mgsloan commented Dec 15, 2017

You probably want to ignore packages from the global package DB (stuff that comes with GHC). You can do this by running the following two commands in bash:

stack exec -- ghc-pkg list --package-db=$(stack path --snapshot-pkg-db)
stack exec -- ghc-pkg list --package-db=$(stack path --local-pkg-db)

@flip111
Copy link
Contributor

flip111 commented Dec 15, 2017

thx @mgsloan next time i want to upgrade my global project i'll use that to grab the package list before i update the resolver

stack exec -- ghc-pkg list --package-db=$(stack path --local-pkg-db) | tail -n+2 | head -n-1 | sed -E -e 's/\s*([a-z-]+)-.*/\1/' | tr '\n' ' '

dsedivec added a commit to dsedivec/macos_ansible that referenced this issue Nov 27, 2019
It turns out Stack is not a package manager.

commercialhaskell/stack#1899
commercialhaskell/stack#1610
https://stackoverflow.com/q/49504206
https://lexi-lambda.github.io/blog/2018/02/10/an-opinionated-guide-to-haskell-in-2018/

Cabal (really cabal-install?) is not a package manager either, per its
docs.

As far as I can tell, something like Python's pip does not exist for
Haskell.  Despair.

Thankfully, MacPorts has upped its Haskell game and now has the latest
ShellCheck.  It even has binaries!  Rejoice!
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

3 participants