[Hackage] #601: cabal setup doesn't respect --prefix

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Keywords: Difficulty: unknown | Ghcversion: Platform: | ----------------------------+----------------------------------------------- I'm trying to install Cabal here. The install process (and the running cabal executable itself) isn't allowed to write into {{{/var/lib}}}, nor into any directory outside of {{{/usr/local/stow/Cabal}}}. So I pass {{{--prefix=/usr/local/stow/Cabal}}} and in addition I use unix permissions to make it so that if it attempts to write outside of the specified prefix it will fail. Good thing I did, because it does indeed so attempt: {{{ ./Setup configure --prefix=/usr/local/stow/Cabal ./Setup build ./Setup install Fri Oct 23 21:29:12 MDT 2009 Installing library in /usr/local/stow/Cabal/lib/Cabal-1.6.0.2/ghc-6.10.4 Registering Cabal-1.6.0.2... Reading package info from "dist/installed-pkg-config" ... done. Writing new package config file... ghc-pkg: /var/lib/ghc-6.10.4/./package.conf: you don't have permission to modify this file }}} Is there a different option to tell it to use a {{{package.conf}}} file in a specific directory? In any case, the fact that it is attempting to write outside the specified {{{--prefix}}} seems like a bug to me. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Resolution: Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment (by zooko): Saizan on IRC told me about the {{{--package-db}}} option. I tried it like this: {{{ ./Setup configure --prefix=/usr/local/stow/Cabal --package- db=/usr/local/stow/Cabal/var/lib/package.conf Configuring Cabal-1.6.0.2... Setup: ghc-pkg dump failed }}} then I wondered if I needed to mkdir the path for it first, so I did: {{{ mkdir -p /usr/local/stow/Cabal/var/lib/ ./Setup configure --prefix=/usr/local/stow/Cabal --package- db=/usr/local/stow/Cabal/var/lib/package.conf Configuring Cabal-1.6.0.2... Setup: ghc-pkg dump failed }}} Then Saizan suggested touching it or echoing [] into it: That did it! {{{ touch /usr/local/stow/Cabal/var/lib/package.conf ./Setup configure --prefix=/usr/local/stow/Cabal --package- db=/usr/local/stow/Cabal/var/lib/package.conf Configuring Cabal-1.6.0.2... Setup: ghc-pkg dump failed echo "[]" >> /usr/local/stow/Cabal/var/lib/package.conf ./Setup configure --prefix=/usr/local/stow/Cabal --package- db=/usr/local/stow/Cabal/var/lib/package.conf Configuring Cabal-1.6.0.2... }}} -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601#comment:1 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Resolution: Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment (by zooko): So, it appears to me that if the user specifies {{{--prefix}}} then that should dictate the location of the package database as well as the other files. The use case described here, in which the install script is strictly disallowed from writing outside of its prescribed prefix, should be supported merely by specifying the prefix. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601#comment:2 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Resolution: Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment (by duncan): Replying to [comment:2 zooko]:
So, it appears to me that if the user specifies {{{--prefix}}} then that should dictate the location of the package database as well as the other files.
This is not possible if you want the installation to work by default. For packages to be used by ghc they must be registered in a package database. There are two default package databases and their location is independent of the prefix used for installing package files. As Saizan says, you can install into a non-default package database and your packages will not be available by default. Instead you will have to use eg: {{{ ghci -package-conf /usr/local/stow/Cabal/var/lib/package.conf }}} Generally people do not actually want that as default behaviour. Hence the default (depending on the --global / --user flag) is to use one of the standard package databases. Supposing there were no global package database then you'd still need some other mechanism to register where packages are, eg Java uses the CLASSPATH etc. Making a persistent change to that requires some similar change to a file that is not inside the selected prefix. Perhaps we can at least make things a bit clearer, eg by checking up-front if we are likely to be able to modify the target package db and giving a more helpful error message. Any other suggestions for what we can improve here, otherwise we should close this ticket. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601#comment:3 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Resolution: wontfix Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Changes (by duncan): * status: new => closed * resolution: => wontfix Comment: Opened #618 about checking in advance if things will fail due to permissions. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601#comment:4 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Resolution: wontfix Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment (by zooko): I don't expect you to fix this, but I just want to reiterate that I think this is a design flaw. The use of a package database makes the hackage package system incompatible with any principle-of-least-authority- respecting installation process, such as GNU stow or Nix. I know it is hard to conceive of an alternative, but there are alternatives, such as using the filesystem as your database, such as GNU stow does. I wonder how Nix handles hackage issue... -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601#comment:5 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#601: cabal setup doesn't respect --prefix ----------------------------+----------------------------------------------- Reporter: zooko | Owner: Type: defect | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.6.0.1 Severity: normal | Resolution: wontfix Keywords: | Difficulty: unknown Ghcversion: | Platform: ----------------------------+----------------------------------------------- Comment (by duncan): What is impossible is being able to install into a completely random location in the filesystem and also have that installed package also be available in the environment by default. Sure, GNU stow uses the filesystem as the DB, but there something knows that the prefix containing the stow store is the database. GHC does not know that. Now you could imagine a design where you did tell ghc "there's an extra global package db at /usr/local/stow/var/ghc/package.conf" and then that location is inside the $prefix that you selected "/usr/local/stow" and so install could write to it. But of course that requires additional configuration to tell ghc that there's going to be this extra package db (and doing that will require writing out of the $prefix). So from a clean ghc installation I don't think there is any way to install packages and have them work by default that doesn't involve writing outside of the $prefix. It can certainly be arranged by prior configuration, but the question is what the defaults should be. Working by default is a fairly high priority. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/601#comment:6 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects
participants (1)
-
Hackage