Commit graph

39 commits

Author SHA1 Message Date
Ian Chen
f897c50202
Fix non-bash output while detecting shell (#2561)
Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2022-12-25 02:35:03 +03:00
Isaac Levy
cc56f76733
Add --no-push-path option (#2526)
In some advanced shell setups, the order of custom-added PATH entries is important.
We disregard it by default, always pushing shims to the front of PATH,
to ensure that Pyenv works even in poorly maintained shell environments
and with minimal hassle for non-export users
(an attempt to do the opposite (#1898) has ended in a disaster).
Some advanced users are however ready and able to carefully maintain their environment
and deal with breakages and inconvenience. This option is for them.
2022-11-19 00:01:59 +03:00
Ivan Pozdeev
6d4365a696 Make pyenv init --path usable as a pyenv init - substitute
We're going to eliminate the need to mandatorily use `pyenv init --path`.
We can't delete it yet for backward compatibility.
Besides, there's one other use case for it: to enable shims but without
shell integration, e.g. for noninteractive shells.

To be a full-fledged replacement for `pyenv init -` however,
it needs to do rehashing.
2022-05-02 19:07:24 +03:00
Ivan Pozdeev
8439f8e187 Simplify init scheme; update & clarify the README
Now the setup is to add to both rc and profile:
1) set PYENV_ROOT
   (can do it unconditionally -- since if you change it,
   you need to update all places anyway since any of them can be run first)
2) Add `pyenv` to PATH if not already there
3) eval "$(pyenv init -)"

Not a breaking change, old setup will continue to work.
2022-05-02 19:07:24 +03:00
Ivan Pozdeev
eb89256f59 Remove the sample code from pyenv init
since there proved to be to many cases to fit
2021-09-19 00:27:03 +03:00
native-api
f7754ae6a4
Remove PATH warning (#2001)
* In some cases (Ubuntu), `pyenv init -` has to be run before `pyenv init --path`.
* The warning has served its purpose by now.
2021-07-03 09:48:13 +03:00
Ivan Pozdeev
3e3f40fefc Warn users to add pyenv init --path to ~/.profile
To facilitate migration
2021-05-05 03:04:52 +03:00
Ivan Pozdeev
7838707595 Separate startup logic into PATH and the rest
PATH manipulation should be done in ~/.profile rather than ~/.*rc since .rc can be sourced multiple times
2021-05-05 03:04:51 +03:00
Ville Skyttä
b5008ce74e test(init): remove misleading detect from parent shell case arg
The generated script does not take/use any arguments, so passing
/bin/zsh to it serves only to cause confusion.
2021-03-23 23:45:32 +02:00
M. Smits
71d2e4549e
Updated documentation pyenv init for fish shell comform to readme. (#1703) 2020-10-01 21:28:29 -04:00
Andrew Rabert
0f596d2504 Revert "Merge pull request #1153 from cmcginty/remove-sbang"
This reverts commit 070e1c859f, reversing
changes made to 3faeda67bb.
2019-04-23 10:23:33 -04:00
Casey McGinty
83e5459cfb Remove shebang lines from scripts for performance
All scripts in libexec/ (excluding pyenv) are called through pyenv,
therefore the shebang lines are not necessary. On some systems this
provides a measurable increase in performance of the shell prompt.

Related to pyenv/pyenv-virtualenv#259
2019-03-07 22:15:14 +01:00
Daniel Hahler
3fd23431af Merge remote-tracking branch 'rbenv/master'
Conflicts:
	README.md
	libexec/pyenv---version
	libexec/pyenv-init
	libexec/rbenv
	libexec/rbenv-sh-shell
	libexec/rbenv-which
	test/init.bats
	test/shell.bats
2017-06-05 15:18:44 +02:00
Jeff Kowalski
a81da8d864 Revert quoting change in previous commit; adjust test to match code
Revert back to original quoting style used before previous commit.
Adjust init.bats to reflect changes for successful tests.
2017-05-16 13:36:06 -07:00
McTavish McArdle
5f20bc258f "." has been deprecated in the fish shell in favor of explicit "source" 2016-05-28 18:29:45 -04:00
Yamashita, Yuu
41ce3aade2 Merge remote-tracking branch 'rbenv/master' into rbenv-1.0 2016-03-02 01:39:52 +00:00
Donald Merand
8b0b51a166 convert references to '.' to 'source' for fish shell 2016-02-20 10:27:39 -05:00
Mislav Marohnić
f9d8b551dc Add test for detecting shell when rbenv init is called from script
References #730
2015-12-24 13:20:49 +01:00
Yamashita, Yuu
8da3749648 Merge remote-tracking branch 'rbenv/master' into rbenv-20151121 2015-11-21 04:21:14 +00:00
Mislav Marohnić
efb187f26f Merge pull request #663 from kevinburke/use-command
Use `command` to run rbenv rehash
2015-10-11 04:04:46 +02:00
Yamashita Yuu
9aee57d965 Fix test for adding shims in fish 2015-05-27 00:54:19 +09:00
Daniel Hahler
10d5d9a24f tests: fix desc for "can add shims to PATH more than once"
This seems to have not been merged properly.

A similar issue is with the test for fish, which has been submitted as a
PR for rbenv: https://github.com/sstephenson/rbenv/pull/722.
2015-04-20 00:00:04 +02:00
Daniel Hahler
06c1959e78 Fix test for adding shims in fish
Commit e2173df4 (for issue #369) did not handle the fish test properly.

This renames it and fixes the assertion.
2015-04-19 23:53:19 +02:00
Yamashita Yuu
f0e852553a Import rbenv changes at 7e0e85bdda 2014-12-01 00:29:26 +09:00
Kevin Burke
c9a96c9f79 Use command to run rbenv rehash
In the event that `eval "$(rbenv init -)"` is called from a function named
rbenv (which I do to get rbenv to load lazily in my shell), evaluating the
phrase `rbenv rehash` will cause the outer function to run again (causing an
infinite loop).

This change makes it clear you want the command named rbenv and not a function
which may exist in the environment.
2014-11-28 21:16:14 -08:00
Mislav Marohnić
39cde6fc95 Merge pull request #528 from sstephenson/dylib
Speed up rbenv by dynamically loading compiled command
2014-10-15 18:19:54 +02:00
Mislav Marohnić
e2173df4aa Revert "Don't duplicate shims in PATH"
Too many of our users have a shell initialization set up that
inadvertently duplicates some or most of the entries in their PATH,
bringing the system paths again in front of rbenv's shims. If this was a
nested shell (a typical scenario when starting up tmux), `rbenv init`
would get eval'd again but this time, shims won't get added to the front
of the PATH and would only stay and the end of the path, effectively
rendering them useless.

I tried to argue that this is a user problem rather than rbenv's, but I
can't fix everybody shell init when they report bugs. Instead, let's
revert to simpler times in rbenv where we just roll along with the
duplication and don't ask any questions.

This reverts commit 03fa148e81.

Fixes #369
2014-10-15 01:43:24 +02:00
Mislav Marohnić
8bac958994 Stop using abs_dirname() in rbenv-init
It's slow and not necessary since we expect `$0` to already be expanded.

In tests this change forces us to deal with some relative paths, but
it's not a big deal. The `rbenv init -` output in the most common case
will be the same as before:

    source '/home/myuser/.rbenv/libexec/../completions/rbenv.bash'
2014-10-13 04:12:34 +02:00
Mislav Marohnić
13a474c4e9 Get rid of explicit exit in fish branch of rbenv-init
Allows for code to be added to the end of the script which will not
mysteriously fail to run for fish shell.
2014-06-03 00:39:34 +07:00
Mislav Marohnić
3dc0005032 Fix test suite running on OpenBSD
The error was "bash: no such file or directory" and it was due to bash
being located in `/usr/local/bin` on OpenBSD 5.4 instead of `/bin` like
on other systems.

Fixed by keeping `/usr/local/bin` in PATH during the test run.
2014-01-02 22:17:38 +01:00
Yamashita Yuu
5dea3c9e63 Import changes from recent rbenv 2014-01-03 04:58:44 +09:00
Yamashita Yuu
0965577b93 Import tests from rbenv with sed -e s/rbenv/pyenv/g 2014-01-03 02:06:36 +09:00
Mislav Marohnić
be5e1a4ded Improve rbenv init instructions for fish
Fish user config file `~/.config/fish/config.fish` loads for every
instance of fish shell, not just interactive ones. Since it's
unnecessary and dangerous to eval `rbenv init -` output in
non-interactive shells, wrap the invocation in a conditional that checks
if the current shell is interactive.

Fixes #501
2013-12-06 16:45:22 +01:00
Mislav Marohnić
878bd87328 reliably detect parent shell in rbenv init
`$SHELL` variable is a terrible way of detecting the current shell
because it's not even supposed to reflect the current shell; it's meant
for keeping the value of the default shell for programs to start.

If an explicit `<shell>` argument wasn't passed to `rbenv init`, it
tries to detect the shell by getting the name of its parent process. If
this fails, it falls back on the value of `$SHELL` as before.

Furthermore, `rbenv init` will set the RBENV_SHELL variable in the
current shell to the value of the detected shell so that `sh-shell` and
`sh-rehash` commands don't have to repeat the detection.
2013-10-07 03:24:45 +02:00
Mislav Marohnić
e97326845c Ubuntu fix: don't use . in place of source
If `rbenv init -` outputs `.` in place of `source` and that gets eval'd
by the desktop manager via `~/.profile`, it chokes and prevents the user
from logging in.

Fixes #457
2013-10-03 16:12:24 +02:00
Mislav Marohnić
31fab8cdae cleanup in fish
Use process subtitution syntax:

    . (rbenv init -|psub)

instead of:

    eval (rbenv init -)

because the latter doesn't work well with newlines.
2013-09-28 16:12:43 +02:00
Yamashita Yuu
5bfec84432 add fish shell support 2013-09-28 16:11:02 +02:00
Mislav Marohnić
bdcc2e1790 check if completion script is readable
fixes #444
2013-09-09 09:53:50 +02:00
Mislav Marohnić
6a6ae8ae46 tests for rbenv-init 2013-03-20 13:43:57 +01:00