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

Invalid $OLDPWD: command "cd -" not working anymore #141

Closed
poncki opened this issue Sep 20, 2016 · 12 comments
Closed

Invalid $OLDPWD: command "cd -" not working anymore #141

poncki opened this issue Sep 20, 2016 · 12 comments
Assignees
Labels
Milestone

Comments

@poncki
Copy link

poncki commented Sep 20, 2016

Hello.

While fixing #125 an error was introduced in ae84a55.
After cd <dir> the $OLDPWD variable is set to a wrong value (a new directory, not the old one) and cd - is not working anymore. Probably this is an effect of setting $PWD in line 14...

pnc

@dasJ dasJ added the type/bug label Sep 21, 2016
@dasJ dasJ added this to the 0.2.1 milestone Sep 21, 2016
dasJ added a commit to dasJ/autoenv that referenced this issue Oct 13, 2016
This allows to use cd -
Closes hyperupcall#141
@dasJ
Copy link
Contributor

dasJ commented Oct 13, 2016

Does #145 fix this for you?

@dasJ dasJ self-assigned this Oct 13, 2016
@dasJ dasJ added waiting and removed waiting labels Oct 13, 2016
@dasJ dasJ closed this as completed Oct 17, 2016
@carhartl
Copy link
Contributor

I'm having the same issue, but I'm not sure whether that may be my zsh setup or not...

@carhartl
Copy link
Contributor

carhartl commented Nov 10, 2016

So basically what I did to fix this for me was moving this line: https://github.com/kennethreitz/autoenv/blob/7eb70eca0039f757525a2f88f008e647a492d7f1/activate.sh#L14

into the subshell:

  # Discover all files we need to source
  # We do this in a subshell so we can cd/chdir
  _files="`
    command -v chdir >/dev/null 2>&1 && \chdir "${_pwd}" || builtin cd "${_pwd}"
    _hadone=''
    while :; do
      _file="$(pwd -P)/${AUTOENV_ENV_FILENAME}"
      if [ -f "${_file}" ]; then
        if [ -z "${_hadone}" ]; then
          echo -n "${_file}"
          _hadone='1'
        else
          echo -n "
${_file}"
        fi
      fi
      [ "$(pwd -P)" = "${_mountpoint}" ] && break
      command -v chdir >/dev/null 2>&1 && \chdir "$(pwd -P)/.." || builtin cd "$(pwd -P)/.."
    done

Afterwards the value of $OLDPWD was intact and cd - worked again. Everything seems to work, though I didn't run any tests yet, just tried it out with an existing .env file.

@n8henrie
Copy link

n8henrie commented Nov 11, 2016

Also suddenly noticed cd - not working, eventually discovered $OLDPWD and can confirm it was incorrect.

Took a fair amount of Googling to find this, the patch fixes the issue for me as well.

EDIT: Clarify, "the patch" is #149

@kennethreitz kennethreitz reopened this Nov 11, 2016
@dasJ
Copy link
Contributor

dasJ commented Nov 11, 2016

As #149 is merged, is this fixed for you?

@dasJ dasJ added the waiting label Nov 11, 2016
@carhartl
Copy link
Contributor

carhartl commented Nov 11, 2016

When homebrew user, while waiting for a new release to be pushed, something like this formalu may help: https://gist.github.com/carhartl/495c498aa1a1ef8a561d2ad53c52b3d6

You'd need to execute brew install --devel autoenv

@carhartl
Copy link
Contributor

Though yeah, might be easier to source activate.sh from somewhere else!

@carhartl
Copy link
Contributor

carhartl commented Nov 11, 2016

And the easiest seems to be:

$ brew uninstall autoenv
$ brew cleanup
$ brew install --HEAD autoenv

@n8henrie
Copy link

n8henrie commented Nov 11, 2016

Yes, issue now seems resolved by installing from HEAD. Thank you!

EDIT: (I am unable to close as I didn't open, @poncki may be able to though.)

@henrahmagix
Copy link

I just came across this problem myself, and installing from HEAD has worked.

Can there please be a stable release soon to homebrew?

@pv8
Copy link

pv8 commented Nov 25, 2017

The release v0.2.1 doesn't actually include the fix for issue #141.

This release is on commit 92d2f3b (Oct 18, 2016) and the fix is on 6c55ec3 (Nov 11, 2016).

@dyson
Copy link

dyson commented Jan 31, 2018

This just got me as well. Would be really great to get a new release out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants