romkatv / zsh4humans

A turnkey configuration for Zsh
MIT License
1.8k stars 116 forks source link

python virtualenv are activated before shims thereby making them unreachable #62

Closed Pilgrim1379 closed 4 years ago

Pilgrim1379 commented 4 years ago

First of all thanks for you time in putting this together. Then problem I'm having is that, I use asdf-vm for managing my programming environment installations and pipenv for python virtualenv environment. Without virtualenvironment activation my path looks like this:

/Users/name/bin
/Users/name/.local/bin
/Users/name/.asdf/shims
/Users/name/.asdf/bin
/Users/name/.emacs.d/bin
/Applications/Postgres.app/Contents/Versions/latest/bin
/usr/local/opt/gettext/bin
/usr/local/opt/curl/bin
/usr/local/opt/grep/libexec/gnubin
/usr/local/opt/findutils/libexec/gnubin
/usr/local/opt/coreutils/libexec/gnubin
/usr/local/opt/sqlite/bin
/Users/name/go/bin
/Users/name/.cargo/bin
/Users/name/.nimble/bin
/usr/local/bin
/usr/local/sbin
/usr/local/Cellar/zsh/5.8/bin
/Users/name/.cache/zsh4humans/v4/fzf/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/name/sdks/flutter/bin

With a virtualenv activated via pipenv my path is now like this:

/Users/name/bin
/Users/name/.local/bin
**/Users/name/.asdf/shims**
/Users/name/.asdf/bin
/Users/name/.emacs.d/bin
/Applications/Postgres.app/Contents/Versions/latest/bin
/usr/local/opt/gettext/bin
/usr/local/opt/curl/bin
/usr/local/opt/grep/libexec/gnubin
/usr/local/opt/findutils/libexec/gnubin
/usr/local/opt/coreutils/libexec/gnubin
/usr/local/opt/sqlite/bin
/Users/name/go/bin
/Users/name/.cargo/bin
/Users/name/.nimble/bin
/usr/local/bin
/usr/local/sbin
/usr/local/Cellar/zsh/5.8/bin
/Users/name/.cache/zsh4humans/v4/fzf/bin
**/Users/name/.virtualenvs/dataanalysis-S7cc-udF/bin**
/usr/bin
/bin
/usr/sbin
/sbin
/Users/name/sdks/flutter/bin

**/Users/name/.virtualenvs/dataanalysis-S7cc-udF/bin** which is the virtual environment is activated before **/Users/name/.asdf/shims**. So when I type python I'm presented with the default python and it's environment rather than the python from the virtual enviroment.

I need a way to cause the virtual environment to be placed ahead of the **/Users/name/.asdf/shims**.

I was using prezto before and didn't have this issue hence my reporting it to you. Below is my .zshrc. I've not touched the .zshenv.

# Personal Zsh configuration file. It is strongly recommended to keep all
# shell customization and configuration (including exported environment
# variables such as PATH) in this file or in files source by it.
#
# Documentation: https://github.com/romkatv/zsh4humans/blob/v4/README.md.

# Periodic auto-update on Zsh startup: 'ask' or 'no'.
zstyle ':z4h:'                auto-update      'ask'
# Ask whether to auto-update this often; has no effect if auto-update is 'no'.
zstyle ':z4h:'                auto-update-days '28'

# Keyboard type: 'mac' or 'pc'.
zstyle ':z4h:bindkey'         keyboard         'mac'
# When fzf menu opens on TAB, another TAB moves the cursor down ('tab:down')
# or accepts the selection and triggers another TAB-completion ('tab:repeat')?
zstyle ':z4h:fzf-complete'    fzf-bindings     'tab:down'
# When fzf menu opens on Shift+Down, TAB moves the cursor down ('tab:down')
# or accepts the selection and triggers another Shift+Down ('tab:repeat')?
zstyle ':z4h:cd-down'         fzf-bindings     'tab:down'
# Right-arrow key accepts one character ('partial-accept') from
# command autosuggestions or the whole thing ('accept')?
zstyle ':z4h:autosuggestions' forward-char     'accept'

# Send these files over to the remote host when connecting over ssh.
# Multiple files can be listed here.
zstyle ':z4h:ssh:*'           send-extra-files '~/.iterm2_shell_integration.zsh'
# Disable automatic teleportation of z4h over ssh when connecting to some-host.
# This makes `ssh some-host` equivalent to `command ssh some-host`.
zstyle ':z4h:ssh:some-host'   passthrough      'yes'

# Move the cursor to the end when Up/Down fetches a command from history?
zstyle ':zle:up-line-or-beginning-search'   leave-cursor 'yes'
zstyle ':zle:down-line-or-beginning-search' leave-cursor 'yes'

# Clone additional Git repositories from GitHub.
#
# This doesn't do anything apart from cloning the repository and keeping it
# up-to-date. Cloned files can be used after `z4h init`. This is just an
# example. If you don't plan to use Oh My Zsh, delete this line.
#z4h install ohmyzsh/ohmyzsh || return

# Install or update core components (fzf, zsh-autosuggestions, etc.) and
# initialize Zsh. After this point console I/O is unavailable until Zsh
# is fully initialized. Everything that requires user interaction or can
# perform network I/O must be done above. Everything else is best done below.
z4h init || return

# Export environment variables.
export GPG_TTY=$TTY

# Source additional local files if they exist.
z4h source ~/.iterm2_shell_integration.zsh

# Define key bindings.
z4h bindkey undo Ctrl+/  # undo the last command line change
z4h bindkey redo Alt+/   # redo the last undone command line change

z4h bindkey z4h-cd-back    Shift+Left   # cd into the previous directory
z4h bindkey z4h-cd-forward Shift+Right  # cd into the next directory
z4h bindkey z4h-cd-up      Shift+Up     # cd into the parent directory
z4h bindkey z4h-cd-down    Shift+Down   # cd into a child directory

# Autoload functions.
autoload -Uz zmv

# Define functions and completions.
function md() { [[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1" }
compdef _directories md

# Replace `ssh` with `z4h ssh` to automatically teleport z4h to remote hosts.
function ssh() { z4h ssh "$@" }

# Define named directories: ~w <=> Windows home directory on WSL.
[[ -n $z4h_win_home ]] && hash -d w=$z4h_win_home

# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots     # no special treatment for file names with a leading dot
setopt no_auto_menu  # require an extra TAB press to open the completion menu

# Load aliases and functions
for file in ~/.{exports,paths,zaliases,functions,private}; do
  [ -r "$file" ] && [ -f "$file" ] && source "$file"
done
unset file

# Colored manpage
man() {
    LESS_TERMCAP_md=$'\e[01;31m' \
    LESS_TERMCAP_me=$'\e[0m' \
    LESS_TERMCAP_se=$'\e[0m' \
    LESS_TERMCAP_so=$'\e[01;44;33m' \
    LESS_TERMCAP_ue=$'\e[0m' \
    LESS_TERMCAP_us=$'\e[01;32m' \
    command man "$@"
}

# append completions to fpath
fpath=(${HOME}/.local/completions ${ASDF_DIR}/completions $fpath)

#asdf
. $HOME/.asdf/asdf.sh

# initialise completions with ZSH's compinit
autoload -Uz compinit
compinit

# Bash completions
autoload -Uz bashcompinit; bashcompinit

# z.lua
eval "$(lua ~/Library/Caches/Homebrew/z.lua--git/z.lua --init zsh enhanced once fzf)"

# pipx
eval "$(register-python-argcomplete pipx)"

# Extend PATH.
path=(~/bin ~/.local/bin $path)

# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path

#neofetch
if [ -v ${VIRTUAL_ENV} ]; then
  neofetch
fi

Thanks

romkatv commented 4 years ago

I've installed your .zshrc. Which command(s) do I need to run to reproduce the issue?

Pilgrim1379 commented 4 years ago

Thanks for getting back, so I don't think it's your configs fault. The issue is with pipenv and how it works. I've been on the zsh irc and this a sample of the conversation I had with some good people there. See below:

thepreacher I have this problem where when I trigger a virtual environment in python, the path to that environment instead of being at the top the the path is somewhere in the middle, there for when I do which python I get the version from the global environment and not the virtual env. I've tried many plugins like zinit prezto zsh4humans with the same outcome.

thepreacher I'm using pipenv btw.

llua your dotfiles is the problem

llua i would assume .zshrc is appending to it, but without them, it is just a guess

llua prepending*

llua software like that expects an setup of your shell

thepreacher I need to remove duplicates from path. I tried typeset -U however it removes the duplicate from the bottom. Is there a way to make it remove from the top of path instead?

Mikachu that would change the result of path lookups

boyd If you really want that (which would be unusual), maybe something like typeset -U temp; temp=( ${(Oa)path} ); path=( $temp ) ? I think that works

Mikachu you'd want to reverse $temp again in the last assignment

thepreacher If any one is so inclined I've pasted the output of my path and a copy of my .zshrc here https://hastebin.com/wezofotoli.bash. You'll notice /Users/nahiable/.virtualenvs/dataanalysis-S7cc-udF/bin which is the path to a virtual environment and /Users/nahiable/.asdf/shims which is the path for asdf-vm shims. This shim folder contains the default python for my system. Now because it comes before the path f

thepreacher or the virtual environment, I'm never able to use the python in my virtual environment. Hope someone can spot my obvious error. I've tried OMZSH, zinit, prezto and attempted to role my own config but the end result is the some as soon as I combine asdf and pipenv.

larryv thepreacher: i expect having all this path manipulation in .zshrc has something to do with it

larryv as opposed to .zprofile or .zlogin

thepreacher @larryv I got there because of the problems I was having. What you see is my attempt at fixing it. I think pipenv is the culprit here because when i tried to role out my own .zshrc, the path was find until I tried activating a virtual env. I don't know what pipenv does when activating a virtual environment but...

thepreacher I'm just going to start from scratch again ..

larryv if you start over and continue doing all this stuff in .zshrc i bet you'll run into the same problem

larryv i'm gonna assume that this is what happens when you run pipenv shell

larryv pipenv / virtualenv prepends the local venv bin to PATH

larryv and then spawns a new interactive shell

thepreacher I assume so too

larryv when that happens, .zshrc is sourced

larryv it prepends all your stuff to PATH

larryv and the venv bin ends up in the middle

Mikachu you can compare echo $$ before and after to see if that's true

thepreacher Yeah I get two different numbers for the before and after

thepreacher Maybe I should use something else apart from pipenv.

larryv so what you're doing is tacking stuff onto the front of PATH every time an interactive shell is invoked

larryv even non-login ones

larryv that is generally not what you want

thepreacher @larryv @Mikachu I've stumbled on a solution. I copied this code from prezto and it's fixed it!! But I don't understand what it does. My venv is now right at the top and there are no duplicates yay!! I put this in my zshenv https://hastebin.com/nivekatako.bash. What does it do anyway.

larryv makes your Rube Goldberg dotfiles machine even more incomprehensible than it was before

larryv it seems intended to ensure that .zprofile is sourced in all top-level shells, even nonlogin ones

So I've got a solution now. You can close this issue. Before you do though if you don't mind can you explain to me what this code does and why it manages to put the virtualenv at the top of the path like I wanted.

if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprofile"
fi

Thanks

romkatv commented 4 years ago

Oh, I see.

You've got a lot of terrible advice in that IRC conversation. What you need is to copy the content of ~/.zprofile to your ~/.zshrc and delete ~/.zprofile. See https://github.com/romkatv/zsh4humans#additional-zsh-startup-files.

When you've installed zsh4humans, it made sure you don't have ~/.zprofile. You must have created it after the installation. Please follow the advice linked above: do not create ~/.zprofile, ~/.zlogin and ~/.zlogout.

romkatv commented 4 years ago

Here are a few comments about your customizations in .zshrc:

# Load aliases and functions
for file in ~/.{exports,paths,zaliases,functions,private}; do
  [ -r "$file" ] && [ -f "$file" ] && source "$file"
done
unset file

The same thing but better:

z4h source -- ~/.{exports,paths,zaliases,functions,private}

# append completions to fpath
fpath=(${HOME}/.local/completions ${ASDF_DIR}/completions $fpath)

Better:

fpath=(~/.local/completions(-/) $fpath)
[[ -n $ASDF_DIR ]] && fpath=($ASDF_DIR/completions(-/) $fpath)

Note that ASDF_DIR is probably unset at that point, so the second line won't do anything. You might want to move it lower in the file.


#asdf
. $HOME/.asdf/asdf.sh

Better:

z4h source ~/.asdf/asdf.sh

# initialise completions with ZSH's compinit
autoload -Uz compinit
compinit

# Bash completions
autoload -Uz bashcompinit; bashcompinit

You need to remove these. They don't do anything good.


# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path

Ditto. Remove this.


#neofetch
if [ -v ${VIRTUAL_ENV} ]; then
  neofetch
fi

If you really want to invoke neofetch form ~/.zshrc, move this block to the top of the file. See the comment above z4h init about console I/O.

Pilgrim1379 commented 4 years ago

Wow thanks for you time. Certainly wasn't expecting you to give me this much attention. I'll have another go with ZSH for Humans and take your suggestions on board. Are you aware of anyone using ZSH for Humans with ASDF and Pipenv?

romkatv commented 4 years ago

Are you aware of anyone using ZSH for Humans with ASDF and Pipenv?

No. However, I'm positive it should work.

Pilgrim1379 commented 4 years ago

Alright thanks again.

Pilgrim1379 commented 4 years ago

Ok so I've reinstalled zsh4humans and made the changes you suggested as you can see from my latest .zshrc file. I didn't touch the .zshenv file at all. There a few issues:

# Personal Zsh configuration file. It is strongly recommended to keep all
# shell customization and configuration (including exported environment
# variables such as PATH) in this file or in files source by it.
#
# Documentation: https://github.com/romkatv/zsh4humans/blob/v4/README.md.

#neofetch
if [ -v ${VIRTUAL_ENV} ]; then
  neofetch
fi

# Periodic auto-update on Zsh startup: 'ask' or 'no'.
zstyle ':z4h:'                auto-update      'ask'
# Ask whether to auto-update this often; has no effect if auto-update is 'no'.
zstyle ':z4h:'                auto-update-days '28'

# Keyboard type: 'mac' or 'pc'.
zstyle ':z4h:bindkey'         keyboard         'mac'
# When fzf menu opens on TAB, another TAB moves the cursor down ('tab:down')
# or accepts the selection and triggers another TAB-completion ('tab:repeat')?
zstyle ':z4h:fzf-complete'    fzf-bindings     'tab:down'
# When fzf menu opens on Shift+Down, TAB moves the cursor down ('tab:down')
# or accepts the selection and triggers another Shift+Down ('tab:repeat')?
zstyle ':z4h:cd-down'         fzf-bindings     'tab:down'
# Right-arrow key accepts one character ('partial-accept') from
# command autosuggestions or the whole thing ('accept')?
zstyle ':z4h:autosuggestions' forward-char     'accept'

# Send these files over to the remote host when connecting over ssh.
# Multiple files can be listed here.
zstyle ':z4h:ssh:*'           send-extra-files '~/.iterm2_shell_integration.zsh'
# Disable automatic teleportation of z4h over ssh when connecting to some-host.
# This makes `ssh some-host` equivalent to `command ssh some-host`.
zstyle ':z4h:ssh:some-host'   passthrough      'yes'

# Move the cursor to the end when Up/Down fetches a command from history?
zstyle ':zle:up-line-or-beginning-search'   leave-cursor 'yes'
zstyle ':zle:down-line-or-beginning-search' leave-cursor 'yes'

# Clone additional Git repositories from GitHub.
#
# This doesn't do anything apart from cloning the repository and keeping it
# up-to-date. Cloned files can be used after `z4h init`. This is just an
# example. If you don't plan to use Oh My Zsh, delete this line.
z4h install ohmyzsh/ohmyzsh || return

# Install or update core components (fzf, zsh-autosuggestions, etc.) and
# initialize Zsh. After this point console I/O is unavailable until Zsh
# is fully initialized. Everything that requires user interaction or can
# perform network I/O must be done above. Everything else is best done below.
z4h init || return

# Export environment variables.
export GPG_TTY=$TTY

# Extend PATH.
path=(~/bin $path)

z4h source -- ~/.{exports,zaliases,functions,private}

# Use additional Git repositories pulled in with `z4h install`.
#
# This is just an example that you should delete. It does nothing useful.
z4h source $Z4H/ohmyzsh/ohmyzsh/lib/diagnostics.zsh
z4h source $Z4H/ohmyzsh/ohmyzsh/plugins/emoji-clock/emoji-clock.plugin.zsh
fpath+=($Z4H/ohmyzsh/ohmyzsh/plugins/supervisor)

# Source additional local files if they exist.
z4h source ~/.iterm2_shell_integration.zsh

# Define key bindings.
z4h bindkey undo Ctrl+/  # undo the last command line change
z4h bindkey redo Alt+/   # redo the last undone command line change

z4h bindkey z4h-cd-back    Shift+Left   # cd into the previous directory
z4h bindkey z4h-cd-forward Shift+Right  # cd into the next directory
z4h bindkey z4h-cd-up      Shift+Up     # cd into the parent directory
z4h bindkey z4h-cd-down    Shift+Down   # cd into a child directory

# Autoload functions.
autoload -Uz zmv

# Define functions and completions.
function md() { [[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1" }
compdef _directories md

# Replace `ssh` with `z4h ssh` to automatically teleport z4h to remote hosts.
function ssh() { z4h ssh "$@" }

# Define named directories: ~w <=> Windows home directory on WSL.
[[ -n $z4h_win_home ]] && hash -d w=$z4h_win_home

# Define aliases.
alias tree='tree -a -I .git'

# Add flags to existing aliases.
alias ls="${aliases[ls]:-ls} -A"

# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots     # no special treatment for file names with a leading dot
setopt no_auto_menu  # require an extra TAB press to open the completion menu

fpath=(~/.local/completions(-/) $fpath)
[[ -n $ASDF_DIR ]] && fpath=($ASDF_DIR/completions(-/) $fpath)

z4h source ~/.asdf/asdf.sh
  1. When I start a new shell I get the message /Users/nahiable/.zshrc:9: command not found: neofetch. However from the command line I can run neofetch without issues.

  2. It appears that $PATH has completely bypassed everything in /etc/path.d folder for macos. There are four application paths setup there that don't show in the $PATH. These are normally sourced automatically without intervention.

  3. The original issue I reported about the virtualenv still exist:

image

As you can see from the image although I'm in the virtual environment, it's running the python from the general .asdf/shims because it's at the top of the path instead of the /Users/nahiable/.virtualenvs/dataanalysis-S7cc-udF/bin

To duplicate this, you'll have to install asdf-vm, then use it to install python. Pipenv also needs to be installed (I installed it with homebrew). Then create a folder somewhere and in that folder typepipenv shell` to create a new virtual environment.

You should at that point be in the newly created virtual environment and do which python. If working correctly it should list the python from the virtual environment.

Thanks a lot.

romkatv commented 4 years ago

Thanks for the details! A couple additional questions:

  1. What is the output of which neofetch?
  2. Do you have ~/.zprofile or ~/.zlogin? If yes, what’s in them?
Pilgrim1379 commented 4 years ago
1. What is the output of `which neofetch`?

/usr/local/bin/neofetch and no I've remove both ~/.zprofile and .zlogin

romkatv commented 4 years ago

What was in them prior to your removing them?

romkatv commented 4 years ago

Perhaps you can post them from ~/zsh-backup?

Pilgrim1379 commented 4 years ago

What was in them prior to your removing them?

I actually deleted them but ~/.zlogin was empty and ~/.zprofile only had the code:

for file in ~/.{exports,paths,private}; do
    [ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;

I think that was more from trying other setups like prezto and oh-my-zsh really.

romkatv commented 4 years ago

So I've got a solution now. You can close this issue. Before you do though if you don't mind can you explain to me what this code does and why it manages to put the virtualenv at the top of the path like I wanted.

if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprofile"
fi

How did this work if there was no ~/.zprofile?

romkatv commented 4 years ago

What I think has happened is that you've created (perhaps not manually but by running some tool) this file after installing zsh4humans. I'm trying to find out what the content of that file was. As I mentioned above, to fix the issue you would need to add the content of that file to ~/.zshrc and then delete the file. Simply deleting the file is incorrect.

Pilgrim1379 commented 4 years ago

So I've got a solution now. You can close this issue. Before you do though if you don't mind can you explain to me what this code does and why it manages to put the virtualenv at the top of the path like I wanted.

if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprofile"
fi

How did this work if there was no ~/.zprofile?

So I was then using oh-my-zsh and that was the only code in .zshenv (I got is from prezto then,

for file in ~/.{exports,paths,private}; do
    [ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;

in the .zprofile.

romkatv commented 4 years ago

What happens if you add this to ~/.zshrc?

z4h source ~/.{exports,paths,private}

Try adding it at the bottom and seeing if this fixes the pipenv issue. If it doesn't, move it above the asdf line.

Pilgrim1379 commented 4 years ago

Ok so I've been messing about with it and it's working now. This is what I've got:

image

The bottom part of the the .zshrc looks like this:


fpath=(~/.local/completions(-/) $fpath)
[[ -n $ASDF_DIR ]] && fpath=($ASDF_DIR/completions(-/) $fpath)

if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) ]]; then
  z4h source ~/.{exports,paths}
fi

z4h source ~/.asdf/asdf.sh

Honestly I don't have a clue what I did and what it means.

romkatv commented 4 years ago

Please post the content of these files: ~/.{exports,paths}

Pilgrim1379 commented 4 years ago

Exports

#!/usr/bin/env bash

# Locale
if [[ -z "$LANG" ]]; then
  # Prefer GB English and use UTF-8
  export LC_ALL="en_GB.UTF-8"
  export LANG="en_GB"
fi

# Browser
if [[ "$OSTYPE" == darwin* ]]; then
  export BROWSER="open"
fi

# Make vim the default editor.
export EDITOR="vim"

# Enable persistent REPL history for `node`.
export NODE_REPL_HISTORY=~/.node_history
# Allow 32³ entries; the default is 1000.
export NODE_REPL_HISTORY_SIZE="32768"
# Use sloppy mode by default, matching web browsers.
export NODE_REPL_MODE="sloppy"
# Node path (to appease ncu-check)
#export NODE_PATH=$(pnpm root --quiet -g)

# Make Python use UTF-8 encoding for output to stdin, stdout, and stderr.
export PYTHONIOENCODING="UTF-8"

# Increase Bash history size. Allow 32³ entries; the default is 500.
export HISTSIZE="32768"
export HISTFILESIZE="${HISTSIZE}"
# Omit duplicates and commands that begin with a space from history.
export HISTCONTROL="ignoreboth"

# Use colors for cli
export CLICOLOR_FORCE=1

# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-F -g -i -M -R -S -w -X -z-4'

# Set the Less input preprocessor.
# Try both `lesspipe` and `lesspipe.sh` as either might exist on a system.
if (( $#commands[(i)lesspipe(|.sh)] )); then
  export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-"
fi

# Don’t clear the screen after quitting a manual page.
export MANPAGER="less -X"

# Avoid issues with `gpg` as installed via Homebrew.
# https://stackoverflow.com/a/42265848/96656
export GPG_TTY=$(tty)

# Hide the “default interactive shell is now zsh” warning on macOS.
export BASH_SILENCE_DEPRECATION_WARNING=1

# Virtualenv
export WORKON_HOME=${HOME}/.virtualenvs

# Android Sdk
export ANDROID_SDK_ROOT=${HOME}/Library/Android/sdk
export ANDROID_HOME=${HOME}/Library/Android/sdk

# Flutter (Dart SDK)
export FLUTTER_ROOT=${HOME}/sdks/flutter/bin

# Vim
export VIMCONFIG=${HOME}/.config/nvim
export VIMDATA=${HOME}/.local/share/nvim
export VISUAL=nvim

# Homebrew
export HOMEBREW_INSTALL_CLEANUP=1
export HOMEBREW_CASK_OPTS="--appdir=/Applications"

# Grep output color
export GREP_COLOR="00;38;5;226"

# Rust
export RUST_SRC_PATH=${HOME}/github/rust

# Golang
export GOPATH=${HOME}/go

#If set, always use fancy mode when invoking pipenv shell.
export PIPENV_SHELL_FANCY=1
#export PIPENV_VENV_IN_PROJECT=1

# fzf
# export FZF_DEFAULT_OPS="--extended"
# export FZF_DEFAULT_COMMAND="fd --type f"
# export FZF_CTRL_T_COMMAND="FZF_DEFAULT_COMMAND"
# export FZ_HISTORY_CD_CMD="_zlua"

# # https://stackoverflow.com/questions/1117398/java-home-directory-in-linux
# Java Home
# export JAVA_HOME=$(/usr/libexec/java_home) # This sets java home to default macos version;
# export JAVA_HOME=$(dirname $(readlink $(which javac)))/java_home # This doesn"t work for asdf;
#export JDK_HOME=$(asdf where java);
#export JDK_HOME=${HOME}/.sdkman/candidates/java/current
#export JAVA_HOME=${JDK_HOME}

# export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home"

# ### To fix python build issues with zlib and gettext ###########################
# export PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2";

# # xcode commandline path
#CPPFLAGS="${CPPFLAGS} -I$(xcrun --show-sdk-path)/usr/include"
# update this for every new macOSX version
#export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk MACOSX_DEPLOYMENT_TARGET=10.15"

# # zlib
#LDFLAGS="${LDFLAGS} -L$(brew --prefix zlib)/lib";
#CPPFLAGS="${CPPFLAGS} -I$(brew --prefix zlib)/include";

# # sqlite
# LDFLAGS="${LDFLAGS} -L$(brew --prefix sqlite)/lib";
# CPPFLAGS="${CPPFLAGS} -I$(brew --prefix sqlite)/include";

# # readline
#LDFLAGS="${LDFLAGS} -L$(brew --prefix readline)/lib";
#CPPFLAGS="${CPPFLAGS} -I$(brew --prefix readline)/include";

# # openssl
#LDFLAGS="${LDFLAGS} -L$(brew --prefix openssl)/lib";
#CPPFLAGS="${CPPFLAGS} -I$(brew --prefix openssl)/include";

# # Gettext
#LDFLAGS="${LDFLAGS} -L/usr/local/opt/gettext/lib";
#CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/gettext/include";

# export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig";
# export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/sqlite/lib/pkgconfig";

# LLVM3
#export LDFLAGS;
#export CPPFLAGS

# Docbook
export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"

# SDK Man
#export SDKMAN_DIR="$HOME/.sdkman"

# Required to enable Python to build dynamic library
# See: https://github.com/danhper/asdf-python/issues/38 (for macos only)
export PYTHON_CONFIGURE_OPTS="--enable-framework"

# Enable IEX Shell History
export ERL_AFLAGS="-kernel shell_history enabled"

# Setup PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/opt/sqlite/lib/pkgconfig

# Compiler flags

# Sqlite3
#LDFLAGS="-L/usr/local/opt/sqlite/lib"
#CPPFLAGS="-I/usr/local/opt/sqlite/include"

# C-C++
#==> Caveats
#To use the bundled libc++ please add the following LDFLAGS:
#  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

#LDFLAGS="-L/usr/local/opt/llvm/lib"
#CPPFLAGS="-I/usr/local/opt/llvm/include"

LDFLAGS=${LDFLAGS}
CPPFLAGS=${CPPFLAGS}

# Export Compiler Flags
export LDFLAGS
export CPPFLAGS

Paths


#!/usr/bin/env bash

# Setup PATHS

### These paths are set by default
### /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools

# LLVM
#PATH=/usr/local/opt/llvm/bin:${PATH}

# Nim
PATH=${HOME}/.nimble/bin:${PATH}

# Rust
PATH=${HOME}/.cargo/bin:${PATH}

# Golang
PATH=${GOPATH}/bin:${PATH}

# Sqlite3
PATH=/usr/local/opt/sqlite/bin:${PATH}

# coreutils
PATH=/usr/local/opt/coreutils/libexec/gnubin:${PATH}

# findutils
PATH=/usr/local/opt/findutils/libexec/gnubin:${PATH}

# grep
PATH=/usr/local/opt/grep/libexec/gnubin:${PATH}

# curl
PATH=/usr/local/opt/curl/bin:${PATH}

# Gettext
PATH=/usr/local/opt/gettext/bin:${PATH}

# flutter
PATH=${PATH}:${HOME}/sdks/flutter/bin

# Postgress app
PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:${PATH}

# Language and SDK Version Managers

# Luaver Config (installed via git)
# Update using git:
# $ cd ~/.luaver && git fetch origin && git reset --hard origin/master
#[ -s ~/.luaver/luaver ] && . ~/.luaver/luaver

# Roswell Common Lisp
#PATH=${HOME}/.roswell/bin:${PATH}

# ASDF Config
# via homebrew
#. $(brew --prefix asdf)/asdf.sh

# Volta config
#[ -s "$VOLTA_HOME/load.sh" ] && . "$VOLTA_HOME/load.sh"
#PATH="${VOLTA_HOME}/bin:${PATH}"

# Poetry (ala Pipenv)
#PATH=${HOME}/.poetry/bin:${PATH}

# Doom emacs
PATH=${HOME}/.emacs.d/bin:${PATH}

# Setup MANPATH

# Export MANPATH
export MANPATH

# Export PGK_CONFIG_PATH
export PKG_CONFIG_PATH

# Export PATH
export PATH
Pilgrim1379 commented 4 years ago

@romkatv So the issue with the pipenv virtual environment was my fault. My shell was misconfigured and what you insisted on moving all exports and paths to .zshrc is correct. I posted the issue here pipenv

The solutions was I moved all my path and exports to my .zshrc and into an if condition like this. The if [[ -o login ]] bit is crucial as without it the problem persists.

if [[ -o login ]]; then
    # Load the env setting and paths and some:
    for file in ~/.{zexports,zpaths}; do
        [ -r "$file" ] && [ -f "$file" ] && source "$file";
    done;
fi

I see you've added a commit to fix the path problem as well so you can close this issue or I'll close it in a little while.

romkatv commented 4 years ago

Thanks for the update.

Closing the issue then. Note that I've fixed the problem with /etc/paths and /etc/paths.d only in v5 (the current development branch) and haven't backported it to v4.