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

allow modification of version via hooks #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djerius
Copy link

@djerius djerius commented Feb 11, 2016

The new internal version-munge command is used to modify the version when
read from a version file or when specified on the command line via the
shell, local, or global commands. The version stored in a version
file is not modified.

This allows the user to modify the version dependent upon the existing
environment. For example, if the PLENV_ROOT directory is shared
across multiple platforms with different OS's, hardware, or ABI's, one
could modify the version at run-time to include a platform specific
suffix, allowing a single version stored in a version file to
accomodate multiple platforms.

For example, if the hostname is used to distinguish the platform, e.g.
on each host Perl was installed with

% plenv install --as 5.22-$(hostname) 5.22

Then with the following hook:

% cat ~/.plenv/plenv.d/version-munge/hostname.bash
#!/bin/bash

if [[ "$version" != --* ]]; then

suffix=$(hostname)

plenv-prefix "$version-$suffix" 1> /dev/null \
    && version="$version-$suffix"

fi

Setting

% plenv global 5.22

will set ~/.plenv/version to 5.22 and the hook will ensure that
each host will see its own version.

@syohex
Copy link
Collaborator

syohex commented Feb 14, 2016

Is it enough to use plenv global 5.22-${hostname} on each platform ?

@djerius
Copy link
Author

djerius commented Feb 14, 2016

PLENV_ROOT is shared by all of the hosts, so PLENV_ROOT/version can't be host specific.

@dolmen
Copy link
Contributor

dolmen commented Mar 22, 2017

An alternative is to not share the same PLENV_ROOT for all hosts.

Here is how to do it:

  • create a different plenv dir for each host:
    git clone https://github.com/tokuhirom/plenv.git ~/.plenv-$(hostname)
  • choose that dir when you load plenv in .profile/.bash_profile/.zshrc:
export PATH="$HOME/.plenv-$(hostname)/bin:$PATH"
eval "$(plenv init -)"

@djerius
Copy link
Author

djerius commented Mar 22, 2017

That would indeed work. I'd prefer of course to have a single plenv dir, as I am consummately lazy.

@dolmen
Copy link
Contributor

dolmen commented Mar 27, 2017

I'd prefer of course to have a single plenv dir, as I am consummately lazy.

I just hope that the lazyness of the maintainers will win. ;-) Any added line of code adds maintenance burden, but also in this case, runtime cost for all users.

@djerius
Copy link
Author

djerius commented Mar 29, 2017

I just hope that the lazyness of the maintainers will win. ;-) Any added line of code adds maintenance burden, but also in this case, runtime cost for all users.

I have faith in their ability to apply the required amount of lazyness. This issue seems to have attracted the appropriate amount of attention from them.

The new internal version-munge command is used to modify the version when
read from a version file or when specified on the command line via the
shell, local, or global commands.  The version stored in a version
file is not modified.

This allows the user to modify the version dependent upon the existing
environment.  For example, if the PLENV_ROOT directory is shared
across multiple platforms with different OS's, hardware, or ABI's, one
could modify the version at run-time to include a platform specific
suffix, allowing a single version stored in a version file to
accomodate multiple platforms.

For example, if the hostname is used to distinguish the platform, e.g.
on each host Perl was installed with

    % plenv install --as 5.22-$(hostname) 5.22

Then with the following hook:

    % cat ~/.plenv/plenv.d/version-munge/hostname.bash
    #!/bin/bash

    if [[ "$version" != --* ]]; then

	suffix=$(hostname)

	plenv-prefix "$version-$suffix" 1> /dev/null \
	    && version="$version-$suffix"

    fi

Setting

    % plenv global 5.22

will set ~/.plenv/version to 5.22 and the hook will ensure that
each host will see its own version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants