如何将目录添加到PATH? [英] How do I add directories to PATH?

查看:285
本文介绍了如何将目录添加到PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总而言之,我正在尝试使用LetsEncrypt向自己颁发SSL证书,并且最近安装了rbenv来简化此过程.安装rbenv后,我检查是否使用

Long story made short, I am trying to issue myself an SSL certificate using LetsEncrypt, and have recently installed rbenv to make this process easier. After installing rbenv, I check to see if everything checks out using

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

我比得到此消息说没有安装任何版本的ruby.尝试使用命令

I than get this message saying that there are no versions of ruby installed. After trying to install ruby using the command

"rbenv install 2.3.1"

我收到此错误

rbenv: no such command `install'

是因为我的rbenv垫片的路径不在我的PATH变量中吗?如果是这种情况,如何将目录添加到PATH变量中?我知道您必须将它们添加到bash_profile文件中,但是不确定在该文件中我需要添加什么内容以及需要添加什么内容.

Is it because the path to my rbenv shims aren't in my PATH variable ? If this is the case how do I add directories to my PATH variable ? I know you have to add them to your bash_profile file, but am not sure where in this file I need to add something, and what I need to add.

〜/.bash_profile

~/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

function letsencrypt_webfaction {
    PATH=$PATH:$GEM_HOME/bin GEM_HOME=$HOME/.letsencrypt_webfaction/gems RUBYLIB=$GEM_HOME/lib ruby2.2 $HOME/.letsencrypt_webfaction/gems/bin/letsencrypt_webfaction $*
}

eval "$(rbenv init -)"


PATH=$PATH:$HOME/bin

export PATH
export PATH="$HOME/.rbenv/bin:$PATH"

推荐答案

在编辑配置文件时始终要小心.

Always be careful when editing the profile.

最好先备份

  • 切换到主目录: cd
  • 列出隐藏文件: ls -la .bash*
  • 制作.bash_profile的备份副本: cp -p .bash_profile .bash_profile.bak
  • 检查当前路径:echo $PATH
  • 检查ruby是否在PATH中:which ruby
  • 检查红宝石版本:ruby --version
  • switch to home directory: cd
  • list hiden files: ls -la .bash*
  • make a backup copy of .bash_profile: cp -p .bash_profile .bash_profile.bak
  • check the current PATH: echo $PATH
  • check if ruby is in the PATH: which ruby
  • check the ruby version: ruby --version

我不确定您的.bash_profile中该功能的来源:function letsencrypt_webfaction()

I am not sure where this function is comming from in your .bash_profile: function letsencrypt_webfaction()

使用:作为分隔符,并在PATH中添加新目录new_dir,使用$PATH保留实际PATH的内容,然后导出新PATH:

Use : as a separator and add a new directory new_dir to your PATH, use $PATH to keep the contents of the actual PATH, then export the new PATH:

PATH=$PATH:/new_dir:/new_lib
export PATH

验证终端是否需要该PATH:echo $PATH

Verify if the PATH is what you need from the terminal: echo $PATH

我个人认为应该直接备份.bash_profile.用#注释该函数的3行以及PATH出现的其他行,并添加以下内容:

Personaly I sugest making a backup of .bash_profile as it is. Comment out with # the 3 lines for the function and the others where the PATH appears and add this:

export RUBYLIB=$HOME/lib
export GEM_HOME=$HOME/gems
export PATH=$HOME/bin:$PATH:

在此之后,请检查上方的小圆点,看看您是否拥有所需的红宝石版本.

After this please check the bulet points above and see if you have the ruby version you expect.

这篇关于如何将目录添加到PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆