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

Command to print all PATH information that can be consumed by the shell #620

Closed
lostman opened this issue Jul 17, 2015 · 6 comments
Closed

Comments

@lostman
Copy link

lostman commented Jul 17, 2015

OCaml's opam has a convenient command to setup environment variables:

❯ opam config env
CAML_LD_LIBRARY_PATH="/Users/lostman/.opam/system/lib/stublibs:/usr/local/lib/ocaml/stublibs"; export CAML_LD_LIBRARY_PATH;
OPAMUTF8MSGS="1"; export OPAMUTF8MSGS;
MANPATH=":/Users/lostman/.opam/system/man"; export MANPATH;
MAKELEVEL=""; export MAKELEVEL;
MAKEFLAGS=""; export MAKEFLAGS;
PERL5LIB="/Users/lostman/.opam/system/lib/perl5"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/Users/lostman/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH;
PATH="/Users/lostman/.opam/system/bin:/Users/lostman/.local/bin:/Users/lostman/.cabal/bin:/Users/lostman/bin:/usr/local/Cellar/llvm/3.4.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin"; export PATH;

Which can be consumed by:

eval `opam config env`

It would be great if stack offered something similar. In particular, when using stack-installed GHC one needs to add it to PATH. Ditto regarding bin/ directory. While stack exec foo works, it is not enough when I want to call more than one binary from a script.

stack config env (or equivalent) could work globally by pointing to the latest GHC version that has been installed and locally in a directory with stack.yaml by pointing to GHC version that is required to build that particular project.

@snoyberg
Copy link
Contributor

Are you aware of stack path?

On Fri, Jul 17, 2015, 8:41 AM Maciej Woś notifications@github.com wrote:

OCaml's opam has a convenient command to setup environment variables:

❯ opam config env
CAML_LD_LIBRARY_PATH="/Users/lostman/.opam/system/lib/stublibs:/usr/local/lib/ocaml/stublibs"; export CAML_LD_LIBRARY_PATH;
OPAMUTF8MSGS="1"; export OPAMUTF8MSGS;
MANPATH=":/Users/lostman/.opam/system/man"; export MANPATH;
MAKELEVEL=""; export MAKELEVEL;
MAKEFLAGS=""; export MAKEFLAGS;
PERL5LIB="/Users/lostman/.opam/system/lib/perl5"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/Users/lostman/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH;
PATH="/Users/lostman/.opam/system/bin:/Users/lostman/.local/bin:/Users/lostman/.cabal/bin:/Users/lostman/bin:/usr/local/Cellar/llvm/3.4.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin"; export PATH;

Which can be consumed by:

eval opam config env

It would be great if stack offered something similar. In particular, when
using stack-installed GHC one needs to add it to PATH. Ditto regarding
bin/ directory. While stack exec foo works, it is not enough when I want
to call more than one binary from a script.

stack config env (or equivalent) could work globally by pointing to the
latest GHC version that has been installed and locally in a directory with
stack.yaml by pointing to GHC version that is required to build that
particular project.


Reply to this email directly or view it on GitHub
#620.

@lostman
Copy link
Author

lostman commented Jul 17, 2015

@snoyberg yes, I've seen stack path. It is different from what I'm talking about though. For instance, bin-path includes all sorts of location, presumably both from PATH and local stack directories. What I think would be useful is a command that can setup all those paths in the current shell.

I just realised that a similar effect can be achieved by issuing stack exec bash or stack exec zsh, but that doesn't display which variables are set and it starts a separate shell.

@snoyberg
Copy link
Contributor

Would you be interested in taking a stab at a PR for this?

@lostman
Copy link
Author

lostman commented Jul 21, 2015

@snoyberg Sure, I'll take a stab at this once I'll have a free weekend.

@sjakobi
Copy link
Member

sjakobi commented Sep 21, 2015

@lostman Does the following command do what you have in mind?

$ comm -23 <(stack exec env | sort) <(env | sort) | sed 's/.*/export &;/'
export GHC_PACKAGE_PATH=/home/simon/src/stack/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/pkgdb:/home/simon/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb:/home/simon/.stack/programs/x86_64-linux/ghc-7.10.2/lib/ghc-7.10.2/package.conf.d;
export HASKELL_DIST_DIR=.stack-work/dist/x86_64-linux/Cabal-1.22.4.0;
export HASKELL_PACKAGE_SANDBOXES=/home/simon/src/stack/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/pkgdb:/home/simon/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb:;
export HASKELL_PACKAGE_SANDBOX=/home/simon/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/pkgdb;
export PATH=/home/simon/src/stack/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/bin:/home/simon/.stack/snapshots/x86_64-linux/lts-3.4/7.10.2/bin:/home/simon/.stack/programs/x86_64-linux/ghc-7.10.2/bin: # snip
export STACK_EXE=/usr/bin/stack;
export _=/usr/bin/stack;

@snoyberg
Copy link
Contributor

PR #4642 open.

snoyberg added a commit that referenced this issue Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants