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

Add "status" command #2882

Closed
wants to merge 2 commits into from
Closed

Add "status" command #2882

wants to merge 2 commits into from

Conversation

lspitzner
Copy link
Collaborator

The "status" command prints a summary over several
aspects of a cabal environment, such as the cabal
and ghc versions, the package and its components,
the package-databases, the sandbox etc.

This is a first proposition for such a command; i am thankful for any feedback.

One thing that might be worth changing is behaviour with flags: Currently there are a few sections printed always, and a few that can be toggled with the flags of the command. Perhaps it would be better to:
a) provide a flag for each section
b) without any flags, print a default set (e.g. the current default)
c) with at least one flag, print exactly the sections selected

I have not tested with compiler != ghc or os != linux.

@lspitzner
Copy link
Collaborator Author

i should add an example for the output from status: (i shortened some of the paths, i.e. $HOME and $SOMEPATH)

> cabal status
cabal-install version 1.23.0.0 compiled using version 1.23.0.0 of the Cabal library 
There is a different cabal (version 1.22.6.0) located in $HOME/.cabal/bin
configured compiler:
  ghc-7.10.2
local package:
  package "cabal-install" containing 3 component(s):
    executable "cabal"
    testsuite "unit-tests"
    testsuite "integration-tests"
sandbox: present in current directory:
  config  in $SOMEPATH/cabal/cabal-install/cabal.sandbox.config
  sandbox in $SOMEPATH/cabal/cabal-install/.cabal-sandbox
  sandbox package db in $SOMEPATH/cabal/cabal-install/.cabal-sandbox/x86_64-linux-ghc-7.10.2-packages.conf.d
package databases:
  12 packages in database $SOMEPATH/cabal/cabal-install/.cabal-sandbox
  25 packages in database /usr/lib/ghc-7.10.2

@dcoutts
Copy link
Contributor

dcoutts commented Oct 22, 2015

I've not looked at the detail of the patch, but in principle I think this is a good idea. I've been thinking of doing something like this for the nix-local-build branch where working out what the environment is is even more critical.

@23Skidoo
Copy link
Member

UI bikeshedding: may be worth unifying this with cabal info, e.g. make cabal info without arguments print this information.

@lspitzner
Copy link
Collaborator Author

@23Skidoo true; when i inserted "status" to the cabal help output, the only command that i had no immediate association for the semantics was "info".

one more thing: the --all output (ellipses inserted by me):

> cabal status --all
cabal-install version 1.23.0.0 compiled using version 1.23.0.0 of the Cabal library 
There is a different cabal (version 1.22.6.0) located in $HOME/.cabal/bin
program versions:
  alex-3.1.4
  c2hs-0.26.1
  cpphs-1.19
  [..]
configured compiler:
  ghc-7.10.2
local package:
  package "cabal-install" containing 3 component(s):
    executable "cabal"
    testsuite "unit-tests"
    testsuite "integration-tests"
install plan:
  Cabal == 1.23.0.0
  array == 0.5.1.0
  base == 4.8.1.0
  [..]
sandbox: present in current directory:
  config  in $SOMEPATH/cabal/cabal-install/cabal.sandbox.config
  sandbox in $SOMEPATH/cabal/cabal-install/.cabal-sandbox
  sandbox package db in $SOMEPATH/cabal/cabal-install/.cabal-sandbox/x86_64-linux-ghc-7.10.2-packages.conf.d
package databases:
  12 packages in database $SOMEPATH/cabal/cabal-install/.cabal-sandbox
    (Cabal-1.23.0.0,
     HTTP-4000.2.20,
     mtl-2.2.1,
     network-2.6.2.1,
     [..]
  25 packages in database /usr/lib/ghc-7.10.2
    (Cabal-1.22.4.0,
     array-0.5.1.0,
     base-4.8.1.0,
     bin-package-db-0.0.0.0,
     [..]
package database checks:
  clean for database GlobalPackageDB
  clean for database UserPackageDB
  clean for database SpecificPackageDB "$SOMEPATH/cabal/cabal-install/.cabal-sandbox/x86_64-linux-ghc-7.10.2-packages.conf.d"

@dcoutts
Copy link
Contributor

dcoutts commented Oct 22, 2015

UI Bikeshedding, I see the info command as separate, it's sort of the equivalent of the hackage package page for packages, rather than "what is going on with my current project". So I'm quite happy with them being separate commands.

@23Skidoo
Copy link
Member

Yes, that's a valid point. On the other hand, the distinction between status and info is not very intuitive.

@lspitzner lspitzner force-pushed the status branch 2 times, most recently from a0f5ece to 8e9c7fa Compare October 24, 2015 10:21
@lspitzner
Copy link
Collaborator Author

How to i handle getExecutablePath with ghc-7.4.2 ?

@23Skidoo
Copy link
Member

How to i handle getExecutablePath with ghc-7.4.2 ?

Doesn't importing Distribution.Client.Compat.ExecutablePath work for you?

@lspitzner
Copy link
Collaborator Author

@23Skidoo ah nice, i was not aware of that, thanks.

@lspitzner
Copy link
Collaborator Author

I did some testing under windows now, looks fine.

@lspitzner
Copy link
Collaborator Author

Are there further changes necessary before this can be merged, or is the main issue that somebody needs to find the time to review this?
(i can think of two potential items: 1) should be tested on macosx (sorry, i don't have that system available) 2) needs entry in some changelog)

Disp.lineLength = 79,
Disp.ribbonsPerLine = 1.0
}
display = Disp.renderStyle defaultStyle . disp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

@23Skidoo
Copy link
Member

23Skidoo commented Nov 5, 2015

A changelog mention and some documentation would be nice.

Documentation lives under Cabal/doc, the changelog is cabal-install/changelog.

multiDesc :: [String] -> String
multiDesc l = "Multiple cabal files found.\n"
++ "Please use only one of: "
++ intercalate ", " l

listPackageDescs :: FilePath -> IO [FilePath]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a Haddock comment explaining what this function does.

@23Skidoo
Copy link
Member

23Skidoo commented Nov 5, 2015

Added some comments. The patches look self-contained (as they should be), so I think this PR can go in.

[Just cabalInstallVersion, Just _cabalVersion] ->
if cabalInstallVersion == Paths_cabal_install.version
then return ()
else putStrLn $ "There is a different cabal (version "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "There is a different 'cabal' executable (version".

@BardurArantsson
Copy link
Collaborator

Just a general comment: I think the individual commits should probably be squashed to a single commit before merge...?

@23Skidoo
Copy link
Member

Yes, that would be nice given that some of the intermediate states don't build cleanly and there is a spurious merge commit.

@lspitzner
Copy link
Collaborator Author

Ok, i'll squash and rebase later.

@lspitzner lspitzner force-pushed the status branch 2 times, most recently from a26a852 to d4d4dfa Compare November 15, 2015 19:28
@lspitzner
Copy link
Collaborator Author

I squashed all commits and rebased onto master.
The changes since the last commit roughly are:

  • Add more haddock/comments, as suggested.
  • Add changelog note.
  • Remove need for CPP in new module.
  • Change handling of flags, in the way i proposed in first comment above.

Questions

  • Should i be the maintainer of the "Status" module (as currently stated in the header)? i don't even have write access to the repo :p. I dont know how this should be handled.
  • The checkPackageDBs function that i added currently does not work when a specific compiler is configured. I don't really know why.
  • I don't really know where to add documentation. I'd guess somewhere in install-packages.markdown, but i have no idea where exactly. Should there be a new "setup status" paragraph? Why "setup"? Probably wrong? Please advice. (To be frank, the whole structure of the users-guide does not make much sense to me, but that is a different topic.)

@23Skidoo
Copy link
Member

Should i be the maintainer of the "Status" module (as currently stated in the header)? i don't even have write access to the repo :p. I dont know how this should be handled.

I don't have a problem with it. I/someone can /cc you on PRs touching this module.

Should there be a new "setup status" paragraph? Why "setup"? Probably wrong? Please advice.

No, not setup status. That refers to Setup.hs scripts. Look at how the sandbox command is documented -- it doesn't have a Setup.hs equivalent either.

(To be frank, the whole structure of the users-guide does not make much sense to me, but that is a different topic.)

Yes, it needs to be reorganised.

@23Skidoo 23Skidoo added this to the cabal-install 1.24.1 milestone Feb 20, 2016
@23Skidoo 23Skidoo modified the milestones: cabal-install 1.24.1, cabal-install 1.24 Feb 23, 2016
@lspitzner
Copy link
Collaborator Author

I added a paragraph about the status command to the users-guide; rebased/squashed onto master again.

For the changelog entry i moved it to 1.25 for now; if you want to still merge this into 1.24 this needs to be changed again.

The testsuite for Cabal fails (locally) for some reason; but it does so on master in the same way, so I cannot test locally (https://gist.github.com/lspitzner/b9cb6a4831147767f24f). The AppVeyor failure seems to be unrelated to this commit as well (?)

Configured compiler:
ghc-7.10.3
~~~~~~~~~~~~~~~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here for the only addition apart from rebasing since last update.

@grayjay
Copy link
Collaborator

grayjay commented Feb 23, 2016

The AppVeyor failure is unrelated to the PR.

@lspitzner
Copy link
Collaborator Author

And sorry for the long wait.

@hvr
Copy link
Member

hvr commented Feb 24, 2016

@lspitzner btw, would an optional JSON representation make sense for cabal status?

@lspitzner
Copy link
Collaborator Author

@hvr I cannot currently see a use-case for JSON output. My intention for this command is to provide some feedback to the human user; for automated settings I would probably tend towards full clean; configure; build cycles, so querying the configuration state is unnecessary. I'd assign a higher priority to JSON representation for the build output, for example (- that does not exist yet, right?).

    The "status" command prints a summary over several
    aspects of a cabal environment, such as the cabal
    and ghc versions, the package and its components,
    the package-databases, the sandbox etc.
@23Skidoo 23Skidoo modified the milestones: cabal-install 1.24, cabal-install 1.24.1 Mar 12, 2016
# Conflicts:
#	Cabal/Distribution/Text.hs
#	Cabal/changelog
#	cabal-install/Distribution/Client/Freeze.hs
#	cabal-install/Distribution/Client/Setup.hs
#	cabal-install/Main.hs
@lspitzner
Copy link
Collaborator Author

Merged master again. Determining the currently configured compiler (version) seems to be broken now. Haven't investigated yet.

@lspitzner
Copy link
Collaborator Author

I have no interest in working on this PR any longer. Has apparently bitrotten by now, although most of the conflicts look like easy to fix.

I'll leave it to you to close this or leave it open; i don't know the policy for this.

@23Skidoo
Copy link
Member

Closing in favour of #3643, which is an updated version of this PR.

@23Skidoo 23Skidoo closed this Jul 29, 2016
@23Skidoo
Copy link
Member

@lspitzner Thank you for working on this PR! I'll try to fix the remaining issues and get it merged.

@gbaz gbaz mentioned this pull request Aug 19, 2021
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants